{
int ret = CALENDAR_ERROR_NONE;
char query[CAL_DB_SQL_MAX_LEN] = {0};
- int calendar_book_id = -1;
- snprintf(query, sizeof(query), "SELECT id FROM %s WHERE id = %d",
- CAL_TABLE_CALENDAR, id);
- ret = cal_db_util_query_get_first_int_result(query, NULL, &calendar_book_id);
- if (CALENDAR_ERROR_NONE != ret) {
- /* LCOV_EXCL_START */
- ERR("cal_db_util_query_get_first_int_result() Fail(%d)", ret);
- return ret;
- /* LCOV_EXCL_STOP */
- }
-
- int count = 0;
- int count2 = 0;
- snprintf(query, sizeof(query), "select count(*) from %s", CAL_TABLE_UTIME_INSTANCE);
- ret = cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret) {
- /* LCOV_EXCL_START */
- ERR("cal_db_util_query_get_first_int_result() Fail");
- return ret;
- /* LCOV_EXCL_STOP */
- }
-
- snprintf(query, sizeof(query), "select count(*) from %s", CAL_TABLE_LOCALTIME_INSTANCE);
- ret = cal_db_util_query_get_first_int_result(query, NULL, &count2);
- if (CALENDAR_ERROR_NONE != ret) {
- /* LCOV_EXCL_START */
- ERR("cal_db_util_query_get_first_int_result() Fail");
- return ret;
- /* LCOV_EXCL_STOP */
- }
-
- count += count2;
-
- if (1000 < count) {
- snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d", CAL_TABLE_CALENDAR, id);
- ret = cal_db_util_query_exec(query);
- RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
- cal_server_cleanup_start();
- } else {
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d", CAL_TABLE_CALENDAR, id);
- ret = cal_db_util_query_exec(query);
- RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
-
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d", CAL_TABLE_SCHEDULE, id);
- ret = cal_db_util_query_exec(query);
- RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
- }
+ snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d", CAL_TABLE_CALENDAR, id);
+ ret = cal_db_util_query_exec(query);
+ RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d", CAL_TABLE_DELETED, id);
+ snprintf(query, sizeof(query), "DELETE FROM "CAL_TABLE_DELETED" WHERE calendar_id = %d", id);
ret = cal_db_util_query_exec(query);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_util_query_exec() Fail(%d)", ret);
cal_access_control_reset();
-
cal_db_util_notify(CAL_NOTI_TYPE_BOOK);
+
return CALENDAR_ERROR_NONE;
}