From: InHong Han Date: Mon, 16 Mar 2020 10:53:59 +0000 (+0900) Subject: Add error codes X-Git-Tag: accepted/tizen/5.5/unified/20200324.134509~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6a60aea32fb77a347eeee9be430b444f2c2a8f5;p=platform%2Fcore%2Fuifw%2Fcapi-ui-sticker.git Add error codes Change-Id: Ibdde0b8c7ed6f1068bc80ccb950e05e3b0925d50 --- diff --git a/client/sticker_data.c b/client/sticker_data.c index b76e7a8..555a23a 100644 --- a/client/sticker_data.c +++ b/client/sticker_data.c @@ -223,7 +223,7 @@ EXPORT_API int sticker_data_get_app_id(sticker_data_h data_handle, char **app_id return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->app_id) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; *app_id = strdup(data_handle->app_id); @@ -268,7 +268,7 @@ EXPORT_API int sticker_data_get_uri(sticker_data_h data_handle, sticker_data_uri return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->type || !data_handle->uri) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; *type = data_handle->type; *uri = strdup(data_handle->uri); @@ -284,7 +284,7 @@ EXPORT_API int sticker_data_foreach_keyword(sticker_data_h data_handle, sticker_ return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->keyword) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; GList *list = NULL; for(list = g_list_first(data_handle->keyword); list != NULL; list=list->next) { @@ -357,7 +357,7 @@ EXPORT_API int sticker_data_get_group_name(sticker_data_h data_handle, char **gr return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->group) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; *group = strdup(data_handle->group); @@ -440,7 +440,7 @@ EXPORT_API int sticker_data_get_date(sticker_data_h data_handle, char **date) return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->date) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; *date = strdup(data_handle->date); diff --git a/client/sticker_dbus.c b/client/sticker_dbus.c index 242e978..8902922 100644 --- a/client/sticker_dbus.c +++ b/client/sticker_dbus.c @@ -667,46 +667,58 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ return ret; } - if (sticker_data->type != 0 && sticker_data->type != origin_data->type) { - LOGD("origin_type : %d, new_type : %d", origin_data->type, sticker_data->type); - ret = _send_sync_message(gdbus_connection, g_variant_new("(ii)", sticker_data->sticker_info_id, sticker_data->type), &reply, "update_sticker_type"); - if (ret != STICKER_CLIENT_ERROR_NONE) - LOGE("failed to update sticker type"); - } - if (sticker_data->uri && strcmp(sticker_data->uri, origin_data->uri) != 0) { LOGD("origin_uri : %s, new_uri : %s", origin_data->uri, sticker_data->uri); ret = _send_sync_message(gdbus_connection, g_variant_new("(isis)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->type, sticker_data->uri), &reply, "update_sticker_uri"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker uri"); + goto cleanup; + } + } + + if (sticker_data->type != 0 && sticker_data->type != origin_data->type) { + LOGD("origin_type : %d, new_type : %d", origin_data->type, sticker_data->type); + ret = _send_sync_message(gdbus_connection, g_variant_new("(ii)", sticker_data->sticker_info_id, sticker_data->type), &reply, "update_sticker_type"); + if (ret != STICKER_CLIENT_ERROR_NONE) { + LOGE("failed to update sticker type"); + goto cleanup; + } } if (sticker_data->thumbnail && strcmp(sticker_data->thumbnail, origin_data->thumbnail) != 0) { LOGD("origin_thumbnail : %s, new_thumbnail : %s", origin_data->thumbnail, sticker_data->thumbnail); ret = _send_sync_message(gdbus_connection, g_variant_new("(is)", sticker_data->sticker_info_id, sticker_data->thumbnail), &reply, "update_sticker_thumbnail"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker thumbnail"); + goto cleanup; + } } if (sticker_data->description && strcmp(sticker_data->description, origin_data->description) != 0) { LOGD("origin_description : %s, new_description : %s", origin_data->description, sticker_data->description); ret = _send_sync_message(gdbus_connection, g_variant_new("(is)", sticker_data->sticker_info_id, sticker_data->description), &reply, "update_sticker_description"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker description"); + goto cleanup; + } } if (sticker_data->group && strcmp(sticker_data->group, origin_data->group) != 0) { LOGD("origin_group : %s, new_group : %s", origin_data->group, sticker_data->group); ret = _send_sync_message(gdbus_connection, g_variant_new("(is)", sticker_data->sticker_info_id, sticker_data->group), &reply, "update_sticker_group"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker group"); + goto cleanup; + } } if (sticker_data->disp_type != 0 && sticker_data->disp_type != origin_data->disp_type) { LOGD("origin_disp_type : %d, new_disp_type : %d", origin_data->disp_type, sticker_data->disp_type); ret = _send_sync_message(gdbus_connection, g_variant_new("(ii)", sticker_data->sticker_info_id, sticker_data->disp_type), &reply, "update_sticker_disp_type"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker display type"); + goto cleanup; + } } if (sticker_data->keyword) { @@ -719,6 +731,7 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ g_variant_builder_unref(keyword_builder); } +cleanup: _free_sticker_data(origin_data); if (reply_body) diff --git a/client/sticker_dbus.h b/client/sticker_dbus.h index 4ef7234..7640435 100644 --- a/client/sticker_dbus.h +++ b/client/sticker_dbus.h @@ -40,6 +40,9 @@ enum sticker_client_error { STICKER_CLIENT_ERROR_SERVICE_NOT_READY, STICKER_CLIENT_ERROR_OPERATION_FAILED, STICKER_CLIENT_ERROR_IO_ERROR, + STICKER_CLIENT_ERROR_DB_FAILED, + STICKER_CLIENT_ERROR_FILE_EXISTS, + STICKER_CLIENT_ERROR_NO_SUCH_FILE, }; int sticker_dbus_init(GDBusConnection **gdbus_connection, int *server_watcher_id, diff --git a/include/sticker_data.h b/include/sticker_data.h index fc1f8c3..e27197c 100644 --- a/include/sticker_data.h +++ b/include/sticker_data.h @@ -123,7 +123,7 @@ int sticker_data_clone(sticker_data_h origin_handle, sticker_data_h *target_hand * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available */ int sticker_data_get_app_id(sticker_data_h data_handle, char **app_id); @@ -139,7 +139,6 @@ int sticker_data_get_app_id(sticker_data_h data_handle, char **app_id); * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed * @see sticker_data_get_uri() */ int sticker_data_set_uri(sticker_data_h data_handle, sticker_data_uri_type_e type, const char *uri); @@ -155,7 +154,7 @@ int sticker_data_set_uri(sticker_data_h data_handle, sticker_data_uri_type_e typ * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available * @see sticker_data_set_uri() */ int sticker_data_get_uri(sticker_data_h data_handle, sticker_data_uri_type_e *type, char **uri); @@ -170,7 +169,7 @@ int sticker_data_get_uri(sticker_data_h data_handle, sticker_data_uri_type_e *ty * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available * @post This function invokes sticker_data_keyword_foreach_cb() repeatedly for getting keywords. * @see sticker_data_keyword_foreach_cb() * @see sticker_data_add_keyword() @@ -234,7 +233,7 @@ int sticker_data_set_group_name(sticker_data_h data_handle, const char *group); * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available * @see sticker_data_set_group() */ int sticker_data_get_group_name(sticker_data_h data_handle, char **group); @@ -309,7 +308,7 @@ int sticker_data_get_description(sticker_data_h data_handle, char **description) * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available */ int sticker_data_get_date(sticker_data_h data_handle, char **date); diff --git a/include/sticker_error.h b/include/sticker_error.h index a38b9c6..fea1302 100644 --- a/include/sticker_error.h +++ b/include/sticker_error.h @@ -45,6 +45,9 @@ typedef enum { STICKER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ STICKER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ STICKER_ERROR_OPERATION_FAILED = TIZEN_ERROR_STICKER | 0x0001, /**< Operation failed */ + STICKER_ERROR_FILE_EXISTS = TIZEN_ERROR_FILE_EXISTS, /**< File exists */ + STICKER_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */ + STICKER_ERROR_NO_SUCH_FILE = TIZEN_ERROR_FILE_EXISTS, /**< No such file */ } sticker_error_e; /** diff --git a/include/sticker_provider.h b/include/sticker_provider.h index 6ea0234..e7367b3 100644 --- a/include/sticker_provider.h +++ b/include/sticker_provider.h @@ -107,6 +107,8 @@ int sticker_provider_destroy(sticker_provider_h provider_handle); * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_FILE_EXISTS File exists + * @retval #STICKER_ERROR_NO_SUCH_FILE No such file * @see sticker_provider_update_data() * @see sticker_provider_delete_data() */ @@ -175,6 +177,8 @@ int sticker_provider_insert_data_by_json_file(sticker_provider_h provider_handle * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_FILE_EXISTS File exists + * @retval #STICKER_ERROR_NO_SUCH_FILE No such file * @see sticker_provider_insert_data() * @see sticker_provider_delete_data() */ diff --git a/provider/sticker_provider.c b/provider/sticker_provider.c index a271ca6..9ef5b60 100644 --- a/provider/sticker_provider.c +++ b/provider/sticker_provider.c @@ -133,7 +133,12 @@ EXPORT_API int sticker_provider_insert_data(sticker_provider_h provider_handle, ret = sticker_dbus_insert_sticker_info(provider_handle->gdbus_connection, data_handle); if (ret != STICKER_ERROR_NONE) { LOGE("Failed to insert sticker information : %d", ret); - return STICKER_ERROR_OPERATION_FAILED; + if (ret == STICKER_CLIENT_ERROR_FILE_EXISTS) + return STICKER_ERROR_FILE_EXISTS; + else if (ret == STICKER_CLIENT_ERROR_NO_SUCH_FILE) + return STICKER_ERROR_NO_SUCH_FILE; + else + return STICKER_ERROR_OPERATION_FAILED; } return STICKER_ERROR_NONE; @@ -233,7 +238,12 @@ EXPORT_API int sticker_provider_update_data(sticker_provider_h provider_handle, ret = sticker_dbus_update_sticker_info(provider_handle->gdbus_connection, data_handle); if (ret != STICKER_ERROR_NONE) { LOGE("Failed to update sticker information : %d", ret); - return STICKER_ERROR_OPERATION_FAILED; + if (ret == STICKER_CLIENT_ERROR_FILE_EXISTS) + return STICKER_ERROR_FILE_EXISTS; + else if (ret == STICKER_CLIENT_ERROR_NO_SUCH_FILE) + return STICKER_ERROR_NO_SUCH_FILE; + else + return STICKER_ERROR_OPERATION_FAILED; } return STICKER_ERROR_NONE; diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 414fc12..f30cd8e 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -572,12 +572,12 @@ int stickerd_insert_sticker_info(GVariant *parameters, GVariant **reply_body) sticker_info->uri = _convert_sticker_uri(sticker_info->uri, sticker_info->app_id); if (!sticker_info->uri) { LOGE("failed to copy sticker file"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; + ret = STICKERD_SERVER_ERROR_FILE_EXISTS; goto cleanup; } } else { LOGE("sticker file does not exist"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; + ret = STICKERD_SERVER_ERROR_NO_SUCH_FILE; goto cleanup; } } @@ -715,6 +715,8 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ sticker_info->uri = _convert_sticker_uri(sticker_info->uri, sticker_info->app_id); if (!sticker_info->uri) goto free_memory; + } else { + goto free_memory; } } @@ -835,8 +837,10 @@ int stickerd_update_sticker_uri(GVariant *parameters, GVariant **reply_body) uri = _convert_sticker_uri(uri, app_id); if (!uri) { LOGE("failed to copy sticker file"); - return STICKERD_SERVER_ERROR_OPERATION_FAILED; + return STICKERD_SERVER_ERROR_FILE_EXISTS; } + } else { + return STICKERD_SERVER_ERROR_NO_SUCH_FILE; } } diff --git a/server/stickerd_error.h b/server/stickerd_error.h index 2afea16..6d1b444 100644 --- a/server/stickerd_error.h +++ b/server/stickerd_error.h @@ -31,13 +31,15 @@ extern "C" { */ enum stickerd_server_error { STICKERD_SERVER_ERROR_NONE, - STICKERD_SERVER_ERROR_IO_ERROR, STICKERD_SERVER_ERROR_INVALID_PARAMETER, STICKERD_SERVER_ERROR_PERMISSION_DENIED, STICKERD_SERVER_ERROR_OUT_OF_MEMORY, STICKERD_SERVER_ERROR_SERVICE_NOT_READY, STICKERD_SERVER_ERROR_OPERATION_FAILED, + STICKERD_SERVER_ERROR_IO_ERROR, STICKERD_SERVER_ERROR_DB_FAILED, + STICKERD_SERVER_ERROR_FILE_EXISTS, + STICKERD_SERVER_ERROR_NO_SUCH_FILE, }; /**