modify terminology:calendar->book,allday->localtime,normal->utime,svc->service
[platform/core/pim/calendar-service.git] / server / db / cal_db_plugin_instance_localtime.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 <stdlib.h>
21
22 #include "cal_internal.h"
23 #include "cal_typedef.h"
24 #include "cal_view.h"
25 #include "cal_record.h"
26 #include "cal_db_util.h"
27 #include "cal_db.h"
28 #include "cal_db_query.h"
29 #include "cal_access_control.h"
30 #include "cal_utils.h"
31
32 static int _cal_db_instance_localtime_delete_record(int id);
33 static int _cal_db_instance_localtime_get_all_records(int offset, int limit, calendar_list_h* out_list);
34 static int _cal_db_instance_localtime_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
35 static int _cal_db_instance_localtime_get_count(int *out_count);
36 static int _cal_db_instance_localtime_get_count_with_query(calendar_query_h query, int *out_count);
37
38 /*
39  * static function
40  */
41 static void _cal_db_instance_localtime_get_stmt(sqlite3_stmt *stmt, calendar_record_h record);
42 static void _cal_db_instance_localtime_get_property_stmt(sqlite3_stmt *stmt,
43                 unsigned int property, int *stmt_count, calendar_record_h record);
44 static void _cal_db_instance_localtime_get_projection_stmt(sqlite3_stmt *stmt,
45                 const unsigned int *projection, const int projection_count,
46                 calendar_record_h record);
47
48 cal_db_plugin_cb_s cal_db_instance_localtime_plugin_cb = {
49         .is_query_only = false,
50         .insert_record = NULL,
51         .get_record = NULL,
52         .update_record = NULL,
53         .delete_record = _cal_db_instance_localtime_delete_record,
54         .get_all_records = _cal_db_instance_localtime_get_all_records,
55         .get_records_with_query = _cal_db_instance_localtime_get_records_with_query,
56         .insert_records = NULL,
57         .update_records = NULL,
58         .delete_records = NULL,
59         .get_count = _cal_db_instance_localtime_get_count,
60         .get_count_with_query = _cal_db_instance_localtime_get_count_with_query,
61         .replace_record = NULL,
62         .replace_records = NULL
63 };
64
65 static int _cal_db_instance_localtime_delete_record(int id)
66 {
67         char query[CAL_DB_SQL_MAX_LEN] = {0};
68         int ret = 0;
69
70         RETVM_IF(id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid argument: id(%d) < 0", id);
71
72         snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id = %d ",
73                         CAL_TABLE_LOCALTIME_INSTANCE, id);
74
75         ret = cal_db_util_query_exec(query);
76         if (CALENDAR_ERROR_NONE != ret) {
77                 /* LCOV_EXCL_START */
78                 ERR("cal_db_util_query_exec() Fail(%d)", ret);
79                 SECURE("[%s]", query);
80                 return ret;
81                 /* LCOV_EXCL_STOP */
82         }
83
84         return CALENDAR_ERROR_NONE;
85 }
86
87 static int _cal_db_instance_localtime_get_all_records(int offset, int limit, calendar_list_h* out_list)
88 {
89         int ret = CALENDAR_ERROR_NONE;
90         char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
91         char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
92         sqlite3_stmt *stmt = NULL;
93
94         RETV_IF(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER);
95
96         ret = calendar_list_create(out_list);
97         RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
98
99         if (0 < offset)
100                 snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
101         if (0 < limit)
102                 snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
103
104         char *query_str = NULL;
105         cal_db_append_string(&query_str, "SELECT * FROM");
106         cal_db_append_string(&query_str, CAL_VIEW_TABLE_LOCALTIME_INSTANCE);
107         cal_db_append_string(&query_str, limitquery);
108         cal_db_append_string(&query_str, offsetquery);
109
110         ret = cal_db_util_query_prepare(query_str, &stmt);
111         if (CALENDAR_ERROR_NONE != ret) {
112                 /* LCOV_EXCL_START */
113                 ERR("cal_db_util_query_prepare() Fail(%d)", ret);
114                 SECURE("query[%s]", query_str);
115                 calendar_list_destroy(*out_list, true);
116                 *out_list = NULL;
117                 free(query_str);
118                 return ret;
119                 /* LCOV_EXCL_STOP */
120         }
121
122         SECURE("[TEST]---------query[%s]", query_str);
123         while (CAL_SQLITE_ROW == cal_db_util_stmt_step(stmt)) {
124                 calendar_record_h record;
125                 ret = calendar_record_create(_calendar_instance_localtime_calendar_book._uri, &record);
126                 if (CALENDAR_ERROR_NONE != ret) {
127                         /* LCOV_EXCL_START */
128                         calendar_list_destroy(*out_list, true);
129                         *out_list = NULL;
130                         sqlite3_finalize(stmt);
131                         CAL_FREE(query_str);
132                         return ret;
133                         /* LCOV_EXCL_STOP */
134                 }
135
136                 _cal_db_instance_localtime_get_stmt(stmt, record);
137
138                 ret = calendar_list_add(*out_list, record);
139                 if (CALENDAR_ERROR_NONE != ret) {
140                         /* LCOV_EXCL_START */
141                         calendar_list_destroy(*out_list, true);
142                         *out_list = NULL;
143                         calendar_record_destroy(record, true);
144                         sqlite3_finalize(stmt);
145                         CAL_FREE(query_str);
146                         return ret;
147                         /* LCOV_EXCL_STOP */
148                 }
149         }
150         sqlite3_finalize(stmt);
151         CAL_FREE(query_str);
152
153         return CALENDAR_ERROR_NONE;
154 }
155
156 static int _cal_db_instance_localtime_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
157 {
158         cal_query_s *que = NULL;
159         int ret = CALENDAR_ERROR_NONE;
160         char *condition = NULL;
161         char *projection = NULL;
162         GSList *bind_text = NULL, *cursor = NULL;
163         sqlite3_stmt *stmt = NULL;
164         int i = 0;
165         char *table_name;
166
167         que = (cal_query_s *)query;
168
169         if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_BOOK)) {
170                 table_name = cal_strdup(CAL_VIEW_TABLE_LOCALTIME_INSTANCE);
171         } else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_BOOK_EXTENDED)) {
172                 table_name = cal_strdup(CAL_VIEW_TABLE_LOCALTIME_INSTANCE_EXTENDED);
173         } else {
174                 /* LCOV_EXCL_START */
175                 ERR("uri(%s) not support get records with query", que->view_uri);
176                 return CALENDAR_ERROR_INVALID_PARAMETER;
177                 /* LCOV_EXCL_STOP */
178         }
179
180         /* make filter */
181         if (que->filter) {
182                 ret = cal_db_query_create_condition(query, &condition, &bind_text);
183                 if (CALENDAR_ERROR_NONE != ret) {
184                         /* LCOV_EXCL_START */
185                         ERR("cal_db_query_create_condition() Fail(%d), ret");
186                         CAL_FREE(table_name);
187                         return ret;
188                         /* LCOV_EXCL_STOP */
189                 }
190         }
191
192         /* make: projection */
193         ret = cal_db_query_create_projection(query, &projection);
194
195         char *query_str = NULL;
196         /* query: projection */
197         if (projection) {
198                 cal_db_append_string(&query_str, "SELECT");
199                 cal_db_append_string(&query_str, projection);
200                 cal_db_append_string(&query_str, "FROM");
201                 cal_db_append_string(&query_str, table_name);
202                 CAL_FREE(projection);
203         } else {
204                 cal_db_append_string(&query_str, "SELECT * FROM");
205                 cal_db_append_string(&query_str, table_name);
206         }
207         CAL_FREE(table_name);
208
209         /* query: condition */
210         if (condition) {
211                 cal_db_append_string(&query_str,  "WHERE (");
212                 cal_db_append_string(&query_str, condition);
213                 cal_db_append_string(&query_str, ")");
214         }
215
216         /* order */
217         char *order = NULL;
218         ret = cal_db_query_create_order(query, condition, &order);
219         if (order) {
220                 cal_db_append_string(&query_str, order);
221                 CAL_FREE(order);
222         }
223         CAL_FREE(condition);
224
225         /* limit, offset */
226         char buf[CAL_STR_SHORT_LEN32] = {0};
227         if (0 < limit) {
228                 snprintf(buf, sizeof(buf), "LIMIT %d", limit);
229                 cal_db_append_string(&query_str, buf);
230
231                 if (0 < offset) {
232                         snprintf(buf, sizeof(buf), "OFFSET %d", offset);
233                         cal_db_append_string(&query_str, buf);
234                 }
235         }
236
237         /* query */
238         ret = cal_db_util_query_prepare(query_str, &stmt);
239         if (CALENDAR_ERROR_NONE != ret) {
240                 /* LCOV_EXCL_START */
241                 ERR("cal_db_util_query_prepare() Fail(%d)", ret);
242                 SECURE("query[%s]", query_str);
243                 if (bind_text) {
244                         g_slist_free_full(bind_text, free);
245                         bind_text = NULL;
246                 }
247                 free(query_str);
248                 return ret;
249                 /* LCOV_EXCL_STOP */
250         }
251
252         /* bind text */
253         if (bind_text) {
254                 g_slist_length(bind_text);
255                 for (cursor = bind_text, i = 1; cursor; cursor = cursor->next, i++)
256                         cal_db_util_stmt_bind_text(stmt, i, cursor->data);
257         }
258
259         ret = calendar_list_create(out_list);
260         if (CALENDAR_ERROR_NONE != ret) {
261                 /* LCOV_EXCL_START */
262                 ERR("calendar_list_create() Fail");
263                 if (bind_text) {
264                         g_slist_free_full(bind_text, free);
265                         bind_text = NULL;
266                 }
267                 sqlite3_finalize(stmt);
268                 CAL_FREE(query_str);
269                 return ret;
270                 /* LCOV_EXCL_STOP */
271         }
272
273         while (CAL_SQLITE_ROW == cal_db_util_stmt_step(stmt)) {
274                 calendar_record_h record;
275                 ret = calendar_record_create(que->view_uri, &record);
276                 if (CALENDAR_ERROR_NONE != ret) {
277                         /* LCOV_EXCL_START */
278                         ERR("calendar_record_create() Fail(%d)", ret);
279                         calendar_list_destroy(*out_list, true);
280                         *out_list = NULL;
281
282                         if (bind_text) {
283                                 g_slist_free_full(bind_text, free);
284                                 bind_text = NULL;
285                         }
286                         sqlite3_finalize(stmt);
287                         CAL_FREE(query_str);
288                         return ret;
289                         /* LCOV_EXCL_STOP */
290                 }
291                 if (0 < que->projection_count) {
292                         cal_record_set_projection(record, que->projection, que->projection_count, que->property_count);
293                         _cal_db_instance_localtime_get_projection_stmt(stmt, que->projection, que->projection_count, record);
294                 } else {
295                         _cal_db_instance_localtime_get_stmt(stmt, record);
296                 }
297
298                 ret = calendar_list_add(*out_list, record);
299                 if (CALENDAR_ERROR_NONE != ret) {
300                         /* LCOV_EXCL_START */
301                         ERR("calendar_list_add() Fail(%d)", ret);
302                         calendar_list_destroy(*out_list, true);
303                         *out_list = NULL;
304                         calendar_record_destroy(record, true);
305
306                         if (bind_text) {
307                                 g_slist_free_full(bind_text, free);
308                                 bind_text = NULL;
309                         }
310                         sqlite3_finalize(stmt);
311                         CAL_FREE(query_str);
312                         return ret;
313                         /* LCOV_EXCL_STOP */
314                 }
315         }
316
317         if (bind_text) {
318                 g_slist_free_full(bind_text, free);
319                 bind_text = NULL;
320         }
321
322         sqlite3_finalize(stmt);
323         CAL_FREE(query_str);
324
325         return CALENDAR_ERROR_NONE;
326 }
327
328 static int _cal_db_instance_localtime_get_count(int *out_count)
329 {
330         RETV_IF(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER);
331
332         char *query_str = NULL;
333         cal_db_append_string(&query_str, "SELECT count(*) FROM");
334         cal_db_append_string(&query_str, CAL_TABLE_LOCALTIME_INSTANCE);
335
336         int ret = 0;
337         int count = 0;
338         ret = cal_db_util_query_get_first_int_result(query_str, NULL, &count);
339         if (CALENDAR_ERROR_NONE != ret) {
340                 /* LCOV_EXCL_START */
341                 ERR("cal_db_util_query_get_first_int_result() Fail");
342                 CAL_FREE(query_str);
343                 return ret;
344                 /* LCOV_EXCL_STOP */
345         }
346         DBG("count(%d) str[%s]", count, query_str);
347         CAL_FREE(query_str);
348
349         *out_count = count;
350         return CALENDAR_ERROR_NONE;
351 }
352
353 static int _cal_db_instance_localtime_get_count_with_query(calendar_query_h query, int *out_count)
354 {
355         cal_query_s *que = NULL;
356         int ret = CALENDAR_ERROR_NONE;
357         char *condition = NULL;
358         char *table_name;
359         int count = 0;
360         GSList *bind_text = NULL;
361
362         que = (cal_query_s *)query;
363
364         if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_BOOK)) {
365                 table_name = cal_strdup(CAL_VIEW_TABLE_LOCALTIME_INSTANCE);
366         } else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_BOOK_EXTENDED)) {
367                 table_name = cal_strdup(CAL_VIEW_TABLE_LOCALTIME_INSTANCE_EXTENDED);
368         } else {
369                 /* LCOV_EXCL_START */
370                 ERR("uri(%s) not support get records with query", que->view_uri);
371                 return CALENDAR_ERROR_INVALID_PARAMETER;
372                 /* LCOV_EXCL_STOP */
373         }
374
375         /* make filter */
376         if (que->filter) {
377                 ret = cal_db_query_create_condition(query, &condition, &bind_text);
378                 if (CALENDAR_ERROR_NONE != ret) {
379                         /* LCOV_EXCL_START */
380                         ERR("cal_db_query_create_condition() Fail(%d), ret");
381                         CAL_FREE(table_name);
382                         return ret;
383                         /* LCOV_EXCL_STOP */
384                 }
385         }
386
387         char *query_str = NULL;
388         /* query: select */
389         cal_db_append_string(&query_str, "SELECT count(*) FROM");
390         cal_db_append_string(&query_str, table_name);
391         CAL_FREE(table_name);
392
393         /* query: condition */
394         if (condition) {
395                 cal_db_append_string(&query_str, "WHERE (");
396                 cal_db_append_string(&query_str, condition);
397                 cal_db_append_string(&query_str, ")");
398                 CAL_FREE(condition);
399         }
400
401         /* query */
402         ret = cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
403         if (CALENDAR_ERROR_NONE != ret) {
404                 /* LCOV_EXCL_START */
405                 ERR("cal_db_util_query_get_first_int_result() Fail");
406                 if (bind_text) {
407                         g_slist_free_full(bind_text, free);
408                         bind_text = NULL;
409                 }
410                 CAL_FREE(query_str);
411                 return ret;
412                 /* LCOV_EXCL_STOP */
413         }
414         DBG("count(%d) str[%s]", count, query_str);
415
416         if (out_count) *out_count = count;
417
418         if (bind_text) {
419                 g_slist_free_full(bind_text, free);
420                 bind_text = NULL;
421         }
422         CAL_FREE(query_str);
423         return CALENDAR_ERROR_NONE;
424 }
425
426 static void _cal_db_instance_localtime_get_stmt(sqlite3_stmt *stmt, calendar_record_h record)
427 {
428         cal_instance_localtime_s* instance =  (cal_instance_localtime_s*)(record);
429         const unsigned char *temp;
430         int count = 0;
431
432         instance->event_id = sqlite3_column_int(stmt, count++);
433         instance->start.type = sqlite3_column_int(stmt, count++);
434         count++; /* utime */
435         temp = sqlite3_column_text(stmt, count++);
436         if (temp) {
437                 sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->start.time.date.year),
438                                 &(instance->start.time.date.month), &(instance->start.time.date.mday),
439                                 &(instance->start.time.date.hour), &(instance->start.time.date.minute),
440                                 &(instance->start.time.date.second));
441                 DBG(CAL_FORMAT_LOCAL_DATETIME, instance->start.time.date.year, instance->start.time.date.month, instance->start.time.date.mday,
442                                 instance->start.time.date.hour, instance->start.time.date.minute, instance->start.time.date.second);
443         }
444
445         instance->end.type = sqlite3_column_int(stmt, count++);
446         count++; /* utime */
447         temp = sqlite3_column_text(stmt, count++);
448         if (temp) {
449                 sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->end.time.date.year),
450                                 &(instance->end.time.date.month), &(instance->end.time.date.mday),
451                                 &(instance->end.time.date.hour), &(instance->end.time.date.minute),
452                                 &(instance->end.time.date.second));
453                 DBG(CAL_FORMAT_LOCAL_DATETIME, instance->end.time.date.year, instance->end.time.date.month, instance->end.time.date.mday,
454                                 instance->end.time.date.hour, instance->end.time.date.minute, instance->end.time.date.second);
455         }
456
457         temp = sqlite3_column_text(stmt, count++);
458         instance->summary = cal_strdup((const char*)temp);
459
460         temp = sqlite3_column_text(stmt, count++);
461         instance->description = cal_strdup((const char*)temp);
462
463         temp = sqlite3_column_text(stmt, count++);
464         instance->location = cal_strdup((const char*)temp);
465
466         instance->busy_status = sqlite3_column_int(stmt, count++);
467
468         instance->event_status = sqlite3_column_int(stmt, count++);
469
470         instance->priority = sqlite3_column_int(stmt, count++);
471
472         instance->sensitivity = sqlite3_column_int(stmt, count++);
473
474         instance->has_rrule = sqlite3_column_int(stmt, count++);
475         if (0 < instance->has_rrule)
476                 instance->has_rrule = 1;
477
478         instance->latitude = sqlite3_column_double(stmt, count++);
479         instance->longitude = sqlite3_column_double(stmt, count++);
480         instance->has_alarm = sqlite3_column_int(stmt, count++);
481         instance->original_event_id = sqlite3_column_int(stmt, count++);
482         instance->calendar_id = sqlite3_column_int(stmt, count++);
483         instance->last_mod = sqlite3_column_int64(stmt, count++);
484
485         temp = sqlite3_column_text(stmt, count++);
486         instance->sync_data1 = cal_strdup((const char*)temp);
487
488         instance->is_allday = sqlite3_column_int(stmt, count++);
489
490         return;
491 }
492
493 static void _cal_db_instance_localtime_get_property_stmt(sqlite3_stmt *stmt,
494                 unsigned int property, int *stmt_count, calendar_record_h record)
495 {
496         cal_instance_localtime_s* instance =  (cal_instance_localtime_s*)(record);
497         const unsigned char *temp;
498
499         switch (property) {
500         case CAL_PROPERTY_INSTANCE_LOCALTIME_START:
501                 instance->start.type = CALENDAR_TIME_LOCALTIME;
502                 *stmt_count = *stmt_count+1; /* utime */
503                 *stmt_count = *stmt_count+1;
504                 temp = sqlite3_column_text(stmt, *stmt_count);
505                 if (temp) {
506                         sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->start.time.date.year),
507                                         &(instance->start.time.date.month), &(instance->start.time.date.mday),
508                                         &(instance->start.time.date.hour), &(instance->start.time.date.minute),
509                                         &(instance->start.time.date.second));
510                 }
511                 break;
512
513         case CAL_PROPERTY_INSTANCE_LOCALTIME_END:
514                 instance->end.type = CALENDAR_TIME_LOCALTIME;
515                 *stmt_count = *stmt_count+1; /* utime */
516                 *stmt_count = *stmt_count+1;
517                 temp = sqlite3_column_text(stmt, *stmt_count);
518                 if (temp) {
519                         sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->end.time.date.year),
520                                         &(instance->end.time.date.month), &(instance->end.time.date.mday),
521                                         &(instance->end.time.date.hour), &(instance->end.time.date.minute),
522                                         &(instance->end.time.date.second));
523                 }
524                 break;
525         case CAL_PROPERTY_INSTANCE_LOCALTIME_SUMMARY:
526                 temp = sqlite3_column_text(stmt, *stmt_count);
527                 instance->summary = cal_strdup((const char*)temp);
528                 break;
529         case CAL_PROPERTY_INSTANCE_LOCALTIME_LOCATION:
530                 temp = sqlite3_column_text(stmt, *stmt_count);
531                 instance->location = cal_strdup((const char*)temp);
532                 break;
533         case CAL_PROPERTY_INSTANCE_LOCALTIME_BOOK_ID:
534                 instance->calendar_id = sqlite3_column_int(stmt, *stmt_count);
535                 break;
536         case CAL_PROPERTY_INSTANCE_LOCALTIME_DESCRIPTION:
537                 temp = sqlite3_column_text(stmt, *stmt_count);
538                 instance->description = cal_strdup((const char*)temp);
539                 break;
540         case CAL_PROPERTY_INSTANCE_LOCALTIME_BUSY_STATUS:
541                 instance->busy_status = sqlite3_column_int(stmt, *stmt_count);
542                 break;
543         case CAL_PROPERTY_INSTANCE_LOCALTIME_EVENT_STATUS:
544                 instance->event_status = sqlite3_column_int(stmt, *stmt_count);
545                 break;
546         case CAL_PROPERTY_INSTANCE_LOCALTIME_PRIORITY:
547                 instance->priority = sqlite3_column_int(stmt, *stmt_count);
548                 break;
549         case CAL_PROPERTY_INSTANCE_LOCALTIME_SENSITIVITY:
550                 instance->sensitivity = sqlite3_column_int(stmt, *stmt_count);
551                 break;
552         case CAL_PROPERTY_INSTANCE_LOCALTIME_HAS_RRULE:
553                 instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
554                 if (0 < instance->has_rrule)
555                         instance->has_rrule = 1;
556
557                 break;
558         case CAL_PROPERTY_INSTANCE_LOCALTIME_LATITUDE:
559                 instance->latitude = sqlite3_column_double(stmt, *stmt_count);
560                 break;
561         case CAL_PROPERTY_INSTANCE_LOCALTIME_LONGITUDE:
562                 instance->longitude = sqlite3_column_double(stmt, *stmt_count);
563                 break;
564         case CAL_PROPERTY_INSTANCE_LOCALTIME_EVENT_ID:
565                 instance->event_id = sqlite3_column_int(stmt, *stmt_count);
566                 break;
567         case CAL_PROPERTY_INSTANCE_LOCALTIME_HAS_ALARM:
568                 instance->has_alarm = sqlite3_column_int(stmt, *stmt_count);
569                 break;
570         case CAL_PROPERTY_INSTANCE_LOCALTIME_ORIGINAL_EVENT_ID:
571                 instance->original_event_id = sqlite3_column_int(stmt, *stmt_count);
572                 break;
573         case CAL_PROPERTY_INSTANCE_LOCALTIME_LAST_MODIFIED_TIME:
574                 instance->last_mod = sqlite3_column_int64(stmt, *stmt_count);
575                 break;
576         case CAL_PROPERTY_INSTANCE_LOCALTIME_SYNC_DATA1:
577                 temp = sqlite3_column_text(stmt, *stmt_count);
578                 instance->sync_data1 = cal_strdup((const char*)temp);
579                 break;
580         case CAL_PROPERTY_INSTANCE_LOCALTIME_IS_ALLDAY:
581                 instance->is_allday = sqlite3_column_int64(stmt, *stmt_count);
582                 break;
583
584         default:
585                 sqlite3_column_int(stmt, *stmt_count);
586                 break;
587         }
588
589         *stmt_count = *stmt_count+1;
590
591         return;
592 }
593
594 static void _cal_db_instance_localtime_get_projection_stmt(sqlite3_stmt *stmt,
595                 const unsigned int *projection, const int projection_count,
596                 calendar_record_h record)
597 {
598         int i = 0;
599         int stmt_count = 0;
600
601         for (i = 0; i < projection_count; i++)
602                 _cal_db_instance_localtime_get_property_stmt(stmt, projection[i], &stmt_count, record);
603 }