ret = app_get_id(&app_id);
if (ret != APP_ERROR_NONE) {
- LOGE("Failed to get app_id : %d", ret);
+ LOGE("Failed to get app_id : %d", ret); //LCOV_EXCL_LINE
ret = STICKER_ERROR_OPERATION_FAILED;
goto cleanup;
}
ret = package_info_create(app_id, &package_info);
if (ret != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
- LOGE("failed to create package_info. ret: %d", ret);
+ LOGE("failed to create package_info. ret: %d", ret); //LCOV_EXCL_LINE
ret = STICKER_ERROR_OPERATION_FAILED;
goto cleanup;
}
ret = package_info_get_root_path(package_info, &app_path);
if (ret != PACKAGE_MANAGER_ERROR_NONE || app_path == NULL) {
- LOGE("failed to create package_info. ret: %d", ret);
+ LOGE("failed to create package_info. ret: %d", ret); //LCOV_EXCL_LINE
ret = STICKER_ERROR_OPERATION_FAILED;
goto cleanup;
}
int path_len = strlen(app_path) + strlen(relative_path) + 2;
file_path = (char *)calloc(path_len, sizeof(char));
if (!file_path) {
- LOGE("failed to alloc memory");
+ LOGE("failed to alloc memory"); //LCOV_EXCL_LINE
ret = STICKER_ERROR_OPERATION_FAILED;
goto cleanup;
}
if(relative_path[0] == '/')
snprintf(file_path, path_len, "%s%s",app_path, relative_path);
else
- snprintf(file_path, path_len, "%s%s%s",app_path, "/", relative_path);
+ snprintf(file_path, path_len, "%s%s%s",app_path, "/", relative_path); //LCOV_EXCL_LINE
if (access(file_path, F_OK) != 0) {
LOGE("%s does not exist", file_path);
return NULL;
}
+static void _free_sticker_data(sticker_data_h sticker_data)
+{
+ if (!sticker_data)
+ return;
+
+ if (sticker_data->app_id) {
+ free(sticker_data->app_id);
+ sticker_data->app_id = NULL;
+ }
+
+ if (sticker_data->uri) {
+ free(sticker_data->uri);
+ sticker_data->uri = NULL;
+ }
+
+ if (sticker_data->thumbnail) {
+ free(sticker_data->thumbnail);
+ sticker_data->thumbnail = NULL;
+ }
+
+ if (sticker_data->keyword) {
+ g_list_free_full(sticker_data->keyword, free);
+ sticker_data->keyword = NULL;
+ }
+
+ if (sticker_data->group) {
+ free(sticker_data->group);
+ sticker_data->group = NULL;
+ }
+
+ if (sticker_data->description) {
+ free(sticker_data->description);
+ sticker_data->description = NULL;
+ }
+
+ if (sticker_data->date) {
+ free(sticker_data->date);
+ sticker_data->date = NULL;
+ }
+
+ free(sticker_data);
+ sticker_data = NULL;
+}
+
EXPORT_API int sticker_data_create(sticker_data_h *data_handle)
{
CHECK_STICKER_FEATURE();
char *app_id = NULL;
int ret = app_get_id(&app_id);
if (ret != APP_ERROR_NONE) {
+ //LCOV_EXCL_START
LOGE("Failed to get app_id : %d", ret);
free(data_struct);
ret = STICKER_ERROR_OPERATION_FAILED;
goto cleanup;
+ //LCOV_EXCL_STOP
}
data_struct->app_id = strdup(app_id);
return STICKER_ERROR_NONE;
}
+EXPORT_API int sticker_data_get_handle(const char* uri, sticker_data_h *data_handle)
+{
+ CHECK_STICKER_FEATURE();
+
+ int ret;
+ GDBusConnection *gdbus_connection = NULL;
+ int server_watcher_id = 0;
+ int monitor_id = 0;
+ int server_monitor_id = 0;
+ int is_exist = 0;
+
+ if (!uri || uri[0] == '\0' || !data_handle)
+ return STICKER_ERROR_INVALID_PARAMETER;
+
+ struct sticker_data_s *handle = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
+ if (!handle)
+ return STICKER_ERROR_OUT_OF_MEMORY;
+
+ ret = sticker_dbus_init(&gdbus_connection, &server_watcher_id, &monitor_id, &server_monitor_id, STICKER_CLIENT_LIB_PROVIDER, NULL);
+ if (ret != STICKER_ERROR_NONE) {
+ LOGE("Failed to initialize dbus : %d", ret);
+ ret = STICKER_ERROR_OPERATION_FAILED;
+ goto cleanup;
+ }
+
+ ret = sticker_dbus_check_file_exists(gdbus_connection, uri, &is_exist);
+ if (ret != STICKER_ERROR_NONE) {
+ LOGE("Failed to check file exists : %d", ret);
+ ret = STICKER_ERROR_OPERATION_FAILED;
+ goto cleanup;
+ }
+
+ if (!is_exist) {
+ LOGE("Sticker does not exist. URI : %s", uri);
+ ret = STICKER_ERROR_NO_SUCH_FILE;
+ goto cleanup;
+ }
+
+ ret = sticker_dbus_get_sticker_info_by_uri(gdbus_connection, handle, uri);
+ if (ret != STICKER_ERROR_NONE) {
+ LOGE("Failed to get sticker information : %d", ret);
+ goto cleanup;
+ }
+
+ *data_handle = handle;
+
+ ret = sticker_dbus_shutdown(gdbus_connection, &server_watcher_id, &server_monitor_id, &monitor_id, STICKER_CLIENT_LIB_PROVIDER);
+ if (ret != STICKER_ERROR_NONE)
+ LOGE("Failed to finalize dbus : %d", ret);
+
+ g_object_unref(gdbus_connection);
+
+ return STICKER_ERROR_NONE;
+
+cleanup:
+ if (handle)
+ _free_sticker_data(handle);
+
+ if (gdbus_connection) {
+ int ret_err = sticker_dbus_shutdown(gdbus_connection, &server_watcher_id, &server_monitor_id, &monitor_id, STICKER_CLIENT_LIB_PROVIDER);
+ if (ret_err != STICKER_ERROR_NONE)
+ LOGE("Failed to finalize dbus : %d", ret_err);
+
+ g_object_unref(gdbus_connection);
+ }
+
+ return ret;
+}
+
EXPORT_API int sticker_data_get_app_id(sticker_data_h data_handle, char **app_id)
{
CHECK_STICKER_FEATURE();
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);
CHECK_STICKER_FEATURE();
char *file_path = NULL;
- if (!data_handle || !type || !uri)
+ if (!data_handle || !type || !uri || uri[0] == '\0')
return STICKER_ERROR_INVALID_PARAMETER;
if (type == STICKER_DATA_URI_LOCAL_PATH) {
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);
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) {
return STICKER_ERROR_INVALID_PARAMETER;
if (!data_handle->group)
- return STICKER_ERROR_OPERATION_FAILED;
+ return STICKER_ERROR_NO_DATA;
*group = strdup(data_handle->group);
CHECK_STICKER_FEATURE();
char *file_path = NULL;
- if (!data_handle || !thumbnail)
+ if (!data_handle || !thumbnail || thumbnail[0] == '\0')
return STICKER_ERROR_INVALID_PARAMETER;
if (access(thumbnail, F_OK) != 0) {
return STICKER_ERROR_INVALID_PARAMETER;
if (!data_handle->date)
- return STICKER_ERROR_OPERATION_FAILED;
+ return STICKER_ERROR_NO_DATA;
*date = strdup(data_handle->date);