modify terminology:calendar->book,allday->localtime,normal->utime,svc->service
[platform/core/pim/calendar-service.git] / server / db / cal_db_instance_helper.c
1 /*
2  * Calendar Service
3  *
4  * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include "cal_typedef.h"
21 #include "cal_db.h"
22 #include "cal_db_util.h"
23 #include "cal_internal.h"
24 #include "calendar_errors.h"
25 #include "cal_db_instance_helper.h"
26
27 int cal_db_instance_helper_insert_utime_instance(int event_id, long long int s, long long int e)
28 {
29         int ret = 0;
30         char query[CAL_DB_SQL_MAX_LEN] = {0};
31         snprintf(query, sizeof(query), "INSERT INTO %s (event_id, dtstart_utime, dtend_utime) "
32                         "VALUES (%d, %lld, %lld) ", CAL_TABLE_UTIME_INSTANCE, event_id, s, e);
33
34         ret = cal_db_util_query_exec(query);
35         if (CALENDAR_ERROR_NONE != ret) {
36                 /* LCOV_EXCL_START */
37                 ERR("cal_db_util_query_exec() Fail(%d)", ret);
38                 SECURE("[%s]", query);
39                 return ret;
40                 /* LCOV_EXCL_STOP */
41         }
42         return CALENDAR_ERROR_NONE;
43 }
44
45 int cal_db_instance_helper_insert_localtime_instance(int event_id, const char *s, const char *e)
46 {
47         int ret = 0;
48         char query[CAL_DB_SQL_MAX_LEN] = {0};
49         snprintf(query, sizeof(query), "INSERT INTO %s (event_id, dtstart_datetime, dtend_datetime) "
50                         "VALUES (%d, '%s', '%s') ", CAL_TABLE_LOCALTIME_INSTANCE, event_id, s, e);
51
52         ret = cal_db_util_query_exec(query);
53         if (CALENDAR_ERROR_NONE != ret) {
54                 /* LCOV_EXCL_START */
55                 ERR("cal_db_util_query_exec() Fail(%d)", ret);
56                 SECURE("[%s]", query);
57                 return ret;
58                 /* LCOV_EXCL_STOP */
59         }
60         return CALENDAR_ERROR_NONE;
61 }
62