modify terminology:calendar->book,allday->localtime,normal->utime,svc->service
[platform/core/pim/calendar-service.git] / server / db / cal_db_plugin_instance_utime_extended.c
 #include "cal_access_control.h"
 #include "cal_utils.h"
 
-static int _cal_db_instance_normal_extended_get_all_records(int offset, int limit, calendar_list_h* out_list);
-static int _cal_db_instance_normal_extended_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
-static int _cal_db_instance_normal_extended_get_count(int *out_count);
-static int _cal_db_instance_normal_extended_get_count_with_query(calendar_query_h query, int *out_count);
+static int _cal_db_instance_utime_extended_get_all_records(int offset, int limit, calendar_list_h* out_list);
+static int _cal_db_instance_utime_extended_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
+static int _cal_db_instance_utime_extended_get_count(int *out_count);
+static int _cal_db_instance_utime_extended_get_count_with_query(calendar_query_h query, int *out_count);
 /*
  * static function
  */
-static void _cal_db_instance_normal_extended_get_stmt(sqlite3_stmt *stmt, calendar_record_h record);
-static void _cal_db_instance_normal_extended_get_property_stmt(sqlite3_stmt *stmt,
+static void _cal_db_instance_utime_extended_get_stmt(sqlite3_stmt *stmt, calendar_record_h record);
+static void _cal_db_instance_utime_extended_get_property_stmt(sqlite3_stmt *stmt,
                unsigned int property, int *stmt_count, calendar_record_h record);
-static void _cal_db_instance_normal_extended_get_projection_stmt(sqlite3_stmt *stmt,
+static void _cal_db_instance_utime_extended_get_projection_stmt(sqlite3_stmt *stmt,
                const unsigned int *projection, const int projection_count,
                calendar_record_h record);
 
-cal_db_plugin_cb_s cal_db_instance_normal_extended_plugin_cb = {
+cal_db_plugin_cb_s cal_db_instance_utime_extended_plugin_cb = {
        .is_query_only = false,
        .insert_record = NULL,
        .get_record = NULL,
        .update_record = NULL,
        .delete_record = NULL,
-       .get_all_records = _cal_db_instance_normal_extended_get_all_records,
-       .get_records_with_query = _cal_db_instance_normal_extended_get_records_with_query,
+       .get_all_records = _cal_db_instance_utime_extended_get_all_records,
+       .get_records_with_query = _cal_db_instance_utime_extended_get_records_with_query,
        .insert_records = NULL,
        .update_records = NULL,
        .delete_records = NULL,
-       .get_count = _cal_db_instance_normal_extended_get_count,
-       .get_count_with_query = _cal_db_instance_normal_extended_get_count_with_query,
+       .get_count = _cal_db_instance_utime_extended_get_count,
+       .get_count_with_query = _cal_db_instance_utime_extended_get_count_with_query,
        .replace_record = NULL,
        .replace_records = NULL
 };
 
-static int _cal_db_instance_normal_extended_get_all_records(int offset, int limit, calendar_list_h* out_list)
+static int _cal_db_instance_utime_extended_get_all_records(int offset, int limit, calendar_list_h* out_list)
 {
        int ret = CALENDAR_ERROR_NONE;
        char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
@@ -80,7 +80,7 @@ static int _cal_db_instance_normal_extended_get_all_records(int offset, int limi
 
        char *query_str = NULL;
        cal_db_append_string(&query_str, "SELECT * FROM");
-       cal_db_append_string(&query_str, CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+       cal_db_append_string(&query_str, CAL_VIEW_TABLE_UTIME_INSTANCE_EXTENDED);
        cal_db_append_string(&query_str, limitquery);
        cal_db_append_string(&query_str, offsetquery);
 
@@ -108,7 +108,7 @@ static int _cal_db_instance_normal_extended_get_all_records(int offset, int limi
                        return ret;
                        /* LCOV_EXCL_STOP */
                }
-               _cal_db_instance_normal_extended_get_stmt(stmt, record);
+               _cal_db_instance_utime_extended_get_stmt(stmt, record);
 
                ret = calendar_list_add(*out_list, record);
                if (CALENDAR_ERROR_NONE != ret) {
@@ -128,7 +128,7 @@ static int _cal_db_instance_normal_extended_get_all_records(int offset, int limi
        return CALENDAR_ERROR_NONE;
 }
 
-static int _cal_db_instance_normal_extended_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
+static int _cal_db_instance_utime_extended_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
 {
        cal_query_s *que = NULL;
        int ret = CALENDAR_ERROR_NONE;
@@ -141,7 +141,7 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
 
        que = (cal_query_s *)query;
 
-       table_name = cal_strdup(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+       table_name = cal_strdup(CAL_VIEW_TABLE_UTIME_INSTANCE_EXTENDED);
 
        /* make filter */
        if (que->filter) {
@@ -257,10 +257,10 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
-                       _cal_db_instance_normal_extended_get_projection_stmt(stmt,
+                       _cal_db_instance_utime_extended_get_projection_stmt(stmt,
                                        que->projection, que->projection_count, record);
                } else {
-                       _cal_db_instance_normal_extended_get_stmt(stmt, record);
+                       _cal_db_instance_utime_extended_get_stmt(stmt, record);
                }
 
                ret = calendar_list_add(*out_list, record);
@@ -291,13 +291,13 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
        return CALENDAR_ERROR_NONE;
 }
 
-static int _cal_db_instance_normal_extended_get_count(int *out_count)
+static int _cal_db_instance_utime_extended_get_count(int *out_count)
 {
        RETV_IF(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER);
 
        char *query_str = NULL;
        cal_db_append_string(&query_str, "SELECT count(*) FROM");
-       cal_db_append_string(&query_str, CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+       cal_db_append_string(&query_str, CAL_VIEW_TABLE_UTIME_INSTANCE_EXTENDED);
 
        int ret = 0;
        int count = 0;
@@ -316,7 +316,7 @@ static int _cal_db_instance_normal_extended_get_count(int *out_count)
        return CALENDAR_ERROR_NONE;
 }
 
-static int _cal_db_instance_normal_extended_get_count_with_query(calendar_query_h query, int *out_count)
+static int _cal_db_instance_utime_extended_get_count_with_query(calendar_query_h query, int *out_count)
 {
        cal_query_s *que = NULL;
        int ret = CALENDAR_ERROR_NONE;
@@ -326,7 +326,7 @@ static int _cal_db_instance_normal_extended_get_count_with_query(calendar_query_
        GSList *bind_text = NULL;
 
        que = (cal_query_s *)query;
-       table_name = cal_strdup(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+       table_name = cal_strdup(CAL_VIEW_TABLE_UTIME_INSTANCE_EXTENDED);
 
        /* make filter */
        if (que->filter) {
@@ -380,9 +380,9 @@ static int _cal_db_instance_normal_extended_get_count_with_query(calendar_query_
        return CALENDAR_ERROR_NONE;
 }
 
-static void _cal_db_instance_normal_extended_get_stmt(sqlite3_stmt *stmt, calendar_record_h record)
+static void _cal_db_instance_utime_extended_get_stmt(sqlite3_stmt *stmt, calendar_record_h record)
 {
-       cal_instance_normal_extended_s* instance =  (cal_instance_normal_extended_s*)(record);
+       cal_instance_utime_extended_s* instance =  (cal_instance_utime_extended_s*)(record);
        const unsigned char *temp;
        int count = 0;
 
@@ -445,102 +445,102 @@ static void _cal_db_instance_normal_extended_get_stmt(sqlite3_stmt *stmt, calend
        return;
 }
 
-static void _cal_db_instance_normal_extended_get_property_stmt(sqlite3_stmt *stmt,
+static void _cal_db_instance_utime_extended_get_property_stmt(sqlite3_stmt *stmt,
                unsigned int property, int *stmt_count, calendar_record_h record)
 {
-       cal_instance_normal_extended_s* instance =  (cal_instance_normal_extended_s*)(record);
+       cal_instance_utime_extended_s* instance =  (cal_instance_utime_extended_s*)(record);
        const unsigned char *temp;
 
        switch (property) {
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_START:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_START:
                instance->start.type = CALENDAR_TIME_UTIME;
                *stmt_count = *stmt_count+1;
                instance->start.time.utime = sqlite3_column_int64(stmt, *stmt_count);
                *stmt_count = *stmt_count+1;
                *stmt_count = *stmt_count+1;
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_END:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_END:
                instance->end.type = CALENDAR_TIME_UTIME;
                *stmt_count = *stmt_count+1;
                instance->end.time.utime = sqlite3_column_int64(stmt, *stmt_count);
                *stmt_count = *stmt_count+1;
                *stmt_count = *stmt_count+1;
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SUMMARY:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_SUMMARY:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->summary = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LOCATION:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_LOCATION:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->location = cal_strdup((const char*)temp);
                break;
-       case  CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CALENDAR_ID:
+       case  CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_BOOK_ID:
                instance->calendar_id = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_DESCRIPTION:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_DESCRIPTION:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->description = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_BUSY_STATUS:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_BUSY_STATUS:
                instance->busy_status = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_STATUS:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_EVENT_STATUS:
                instance->event_status = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_PRIORITY:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_PRIORITY:
                instance->priority = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SENSITIVITY:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_SENSITIVITY:
                instance->sensitivity = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_HAS_RRULE:
                instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
                if (0 < instance->has_rrule)
                        instance->has_rrule = 1;
 
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LATITUDE:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_LATITUDE:
                instance->latitude = sqlite3_column_double(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LONGITUDE:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_LONGITUDE:
                instance->longitude = sqlite3_column_double(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_ID:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_EVENT_ID:
                instance->event_id = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ALARM:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_HAS_ALARM:
                instance->has_alarm = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORIGINAL_EVENT_ID:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_ORIGINAL_EVENT_ID:
                instance->original_event_id = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LAST_MODIFIED_TIME:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_LAST_MODIFIED_TIME:
                instance->last_mod = sqlite3_column_int64(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA1:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_SYNC_DATA1:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->sync_data1 = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORGANIZER_NAME:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_ORGANIZER_NAME:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->organizer_name = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CATEGORIES:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_CATEGORIES:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->categories = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ATTENDEE:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_HAS_ATTENDEE:
                instance->has_attendee = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA2:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_SYNC_DATA2:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->sync_data2 = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA3:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_SYNC_DATA3:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->sync_data3 = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA4:
+       case CAL_PROPERTY_INSTANCE_UTIME_EXTENDED_SYNC_DATA4:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->sync_data4 = cal_strdup((const char*)temp);
                break;
@@ -554,7 +554,7 @@ static void _cal_db_instance_normal_extended_get_property_stmt(sqlite3_stmt *stm
        return;
 }
 
-static void _cal_db_instance_normal_extended_get_projection_stmt(sqlite3_stmt *stmt,
+static void _cal_db_instance_utime_extended_get_projection_stmt(sqlite3_stmt *stmt,
                const unsigned int *projection, const int projection_count,
                calendar_record_h record)
 {
@@ -562,5 +562,5 @@ static void _cal_db_instance_normal_extended_get_projection_stmt(sqlite3_stmt *s
        int stmt_count = 0;
 
        for (i = 0; i < projection_count; i++)
-               _cal_db_instance_normal_extended_get_property_stmt(stmt, projection[i], &stmt_count, record);
+               _cal_db_instance_utime_extended_get_property_stmt(stmt, projection[i], &stmt_count, record);
 }