modify terminology:calendar->book,allday->localtime,normal->utime,svc->service
[platform/core/pim/calendar-service.git] / server / db / cal_db_plugin_instance_utime.c
similarity index 79%
rename from server/db/cal_db_plugin_instance_normal.c
rename to server/db/cal_db_plugin_instance_utime.c
index 79a5b0e..c72a2c9 100644 (file)
 #include "cal_access_control.h"
 #include "cal_utils.h"
 
-static int _cal_db_instance_normal_delete_record(int id);
-static int _cal_db_instance_normal_get_all_records(int offset, int limit, calendar_list_h* out_list);
-static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
-static int _cal_db_instance_normal_get_count(int *out_count);
-static int _cal_db_instance_normal_get_count_with_query(calendar_query_h query, int *out_count);
+static int _cal_db_instance_utime_delete_record(int id);
+static int _cal_db_instance_utime_get_all_records(int offset, int limit, calendar_list_h* out_list);
+static int _cal_db_instance_utime_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
+static int _cal_db_instance_utime_get_count(int *out_count);
+static int _cal_db_instance_utime_get_count_with_query(calendar_query_h query, int *out_count);
 
 /*
  * static function
  */
-static void _cal_db_instance_normal_get_stmt(sqlite3_stmt *stmt, calendar_record_h record);
-static void _cal_db_instance_normal_get_property_stmt(sqlite3_stmt *stmt,
+static void _cal_db_instance_utime_get_stmt(sqlite3_stmt *stmt, calendar_record_h record);
+static void _cal_db_instance_utime_get_property_stmt(sqlite3_stmt *stmt,
                unsigned int property, int *stmt_count, calendar_record_h record);
-static void _cal_db_instance_normal_get_projection_stmt(sqlite3_stmt *stmt,
+static void _cal_db_instance_utime_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_plugin_cb = {
+cal_db_plugin_cb_s cal_db_instance_utime_plugin_cb = {
        .is_query_only = false,
        .insert_record = NULL,
        .get_record = NULL,
        .update_record = NULL,
-       .delete_record = _cal_db_instance_normal_delete_record,
-       .get_all_records = _cal_db_instance_normal_get_all_records,
-       .get_records_with_query = _cal_db_instance_normal_get_records_with_query,
+       .delete_record = _cal_db_instance_utime_delete_record,
+       .get_all_records = _cal_db_instance_utime_get_all_records,
+       .get_records_with_query = _cal_db_instance_utime_get_records_with_query,
        .insert_records = NULL,
        .update_records = NULL,
        .delete_records = NULL,
-       .get_count = _cal_db_instance_normal_get_count,
-       .get_count_with_query = _cal_db_instance_normal_get_count_with_query,
+       .get_count = _cal_db_instance_utime_get_count,
+       .get_count_with_query = _cal_db_instance_utime_get_count_with_query,
        .replace_record = NULL,
        .replace_records = NULL
 };
 
-static int _cal_db_instance_normal_delete_record(int id)
+static int _cal_db_instance_utime_delete_record(int id)
 {
        int ret = 0;
        char query[CAL_DB_SQL_MAX_LEN] = {0};
@@ -74,7 +74,7 @@ static int _cal_db_instance_normal_delete_record(int id)
        snprintf(query, sizeof(query),
                        "DELETE FROM %s "
                        "WHERE event_id = %d ",
-                       CAL_TABLE_NORMAL_INSTANCE,
+                       CAL_TABLE_UTIME_INSTANCE,
                        id);
 
        ret = cal_db_util_query_exec(query);
@@ -89,7 +89,7 @@ static int _cal_db_instance_normal_delete_record(int id)
        return CALENDAR_ERROR_NONE;
 }
 
-static int _cal_db_instance_normal_get_all_records(int offset, int limit, calendar_list_h* out_list)
+static int _cal_db_instance_utime_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};
@@ -108,7 +108,7 @@ static int _cal_db_instance_normal_get_all_records(int offset, int limit, calend
 
        char *query_str = NULL;
        cal_db_append_string(&query_str, "SELECT * FROM");
-       cal_db_append_string(&query_str, CAL_VIEW_TABLE_NORMAL_INSTANCE);
+       cal_db_append_string(&query_str, CAL_VIEW_TABLE_UTIME_INSTANCE);
        cal_db_append_string(&query_str, limitquery);
        cal_db_append_string(&query_str, offsetquery);
 
@@ -137,7 +137,7 @@ static int _cal_db_instance_normal_get_all_records(int offset, int limit, calend
                        return ret;
                        /* LCOV_EXCL_STOP */
                }
-               _cal_db_instance_normal_get_stmt(stmt, record);
+               _cal_db_instance_utime_get_stmt(stmt, record);
 
                ret = calendar_list_add(*out_list, record);
                if (CALENDAR_ERROR_NONE != ret) {
@@ -157,7 +157,7 @@ static int _cal_db_instance_normal_get_all_records(int offset, int limit, calend
        return CALENDAR_ERROR_NONE;
 }
 
-static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
+static int _cal_db_instance_utime_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;
@@ -170,10 +170,10 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR)) {
-               table_name = cal_strdup(CAL_VIEW_TABLE_NORMAL_INSTANCE);
-       } else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED)) {
-               table_name = cal_strdup(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_BOOK)) {
+               table_name = cal_strdup(CAL_VIEW_TABLE_UTIME_INSTANCE);
+       } else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_BOOK_EXTENDED)) {
+               table_name = cal_strdup(CAL_VIEW_TABLE_UTIME_INSTANCE_EXTENDED);
        } else {
                /* LCOV_EXCL_START */
                ERR("uri(%s) not support get records with query", que->view_uri);
@@ -294,11 +294,11 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
-                       _cal_db_instance_normal_get_projection_stmt(stmt,
+                       _cal_db_instance_utime_get_projection_stmt(stmt,
                                        que->projection, que->projection_count,
                                        record);
                } else {
-                       _cal_db_instance_normal_get_stmt(stmt, record);
+                       _cal_db_instance_utime_get_stmt(stmt, record);
                }
 
                ret = calendar_list_add(*out_list, record);
@@ -329,13 +329,13 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
        return CALENDAR_ERROR_NONE;
 }
 
-static int _cal_db_instance_normal_get_count(int *out_count)
+static int _cal_db_instance_utime_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_TABLE_NORMAL_INSTANCE);
+       cal_db_append_string(&query_str, CAL_TABLE_UTIME_INSTANCE);
 
        int ret = 0;
        int count = 0;
@@ -353,7 +353,7 @@ static int _cal_db_instance_normal_get_count(int *out_count)
        return CALENDAR_ERROR_NONE;
 }
 
-static int _cal_db_instance_normal_get_count_with_query(calendar_query_h query, int *out_count)
+static int _cal_db_instance_utime_get_count_with_query(calendar_query_h query, int *out_count)
 {
        cal_query_s *que = NULL;
        int ret = CALENDAR_ERROR_NONE;
@@ -364,10 +364,10 @@ static int _cal_db_instance_normal_get_count_with_query(calendar_query_h query,
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR)) {
-               table_name = cal_strdup(CAL_VIEW_TABLE_NORMAL_INSTANCE);
-       } else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED)) {
-               table_name = cal_strdup(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_BOOK)) {
+               table_name = cal_strdup(CAL_VIEW_TABLE_UTIME_INSTANCE);
+       } else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_BOOK_EXTENDED)) {
+               table_name = cal_strdup(CAL_VIEW_TABLE_UTIME_INSTANCE_EXTENDED);
        } else {
                /* LCOV_EXCL_START */
                ERR("uri(%s) not support get records with query", que->view_uri);
@@ -427,9 +427,9 @@ static int _cal_db_instance_normal_get_count_with_query(calendar_query_h query,
        return CALENDAR_ERROR_NONE;
 }
 
-static void _cal_db_instance_normal_get_stmt(sqlite3_stmt *stmt, calendar_record_h record)
+static void _cal_db_instance_utime_get_stmt(sqlite3_stmt *stmt, calendar_record_h record)
 {
-       cal_instance_normal_s* instance =  (cal_instance_normal_s*)(record);
+       cal_instance_utime_s* instance =  (cal_instance_utime_s*)(record);
        const unsigned char *temp;
        int count = 0;
 
@@ -475,78 +475,78 @@ static void _cal_db_instance_normal_get_stmt(sqlite3_stmt *stmt, calendar_record
        return;
 }
 
-static void _cal_db_instance_normal_get_property_stmt(sqlite3_stmt *stmt,
+static void _cal_db_instance_utime_get_property_stmt(sqlite3_stmt *stmt,
                unsigned int property, int *stmt_count, calendar_record_h record)
 {
-       cal_instance_normal_s* instance =  (cal_instance_normal_s*)(record);
+       cal_instance_utime_s* instance =  (cal_instance_utime_s*)(record);
        const unsigned char *temp;
 
        switch (property) {
-       case CAL_PROPERTY_INSTANCE_NORMAL_START:
+       case CAL_PROPERTY_INSTANCE_UTIME_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; /* datatime */
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_END:
+       case CAL_PROPERTY_INSTANCE_UTIME_END:
                instance->end.type = CALENDAR_TIME_UTIME;
                sqlite3_column_int(stmt, *stmt_count);
                *stmt_count = *stmt_count+1;
                instance->end.time.utime = sqlite3_column_int64(stmt, *stmt_count);
                *stmt_count = *stmt_count+1; /* datatime */
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
+       case CAL_PROPERTY_INSTANCE_UTIME_SUMMARY:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->summary = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_LOCATION:
+       case CAL_PROPERTY_INSTANCE_UTIME_LOCATION:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->location = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID:
+       case CAL_PROPERTY_INSTANCE_UTIME_BOOK_ID:
                instance->calendar_id = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION:
+       case CAL_PROPERTY_INSTANCE_UTIME_DESCRIPTION:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->description = cal_strdup((const char*)temp);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS:
+       case CAL_PROPERTY_INSTANCE_UTIME_BUSY_STATUS:
                instance->busy_status = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS:
+       case CAL_PROPERTY_INSTANCE_UTIME_EVENT_STATUS:
                instance->event_status = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY:
+       case CAL_PROPERTY_INSTANCE_UTIME_PRIORITY:
                instance->priority = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY:
+       case CAL_PROPERTY_INSTANCE_UTIME_SENSITIVITY:
                instance->sensitivity = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
+       case CAL_PROPERTY_INSTANCE_UTIME_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_LATITUDE:
+       case CAL_PROPERTY_INSTANCE_UTIME_LATITUDE:
                instance->latitude = sqlite3_column_double(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE:
+       case CAL_PROPERTY_INSTANCE_UTIME_LONGITUDE:
                instance->longitude = sqlite3_column_double(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID:
+       case CAL_PROPERTY_INSTANCE_UTIME_EVENT_ID:
                instance->event_id = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM:
+       case CAL_PROPERTY_INSTANCE_UTIME_HAS_ALARM:
                instance->has_alarm = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID:
+       case CAL_PROPERTY_INSTANCE_UTIME_ORIGINAL_EVENT_ID:
                instance->original_event_id = sqlite3_column_int(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME:
+       case CAL_PROPERTY_INSTANCE_UTIME_LAST_MODIFIED_TIME:
                instance->last_mod = sqlite3_column_int64(stmt, *stmt_count);
                break;
-       case CAL_PROPERTY_INSTANCE_NORMAL_SYNC_DATA1:
+       case CAL_PROPERTY_INSTANCE_UTIME_SYNC_DATA1:
                temp = sqlite3_column_text(stmt, *stmt_count);
                instance->sync_data1 = cal_strdup((const char*)temp);
                break;
@@ -560,7 +560,7 @@ static void _cal_db_instance_normal_get_property_stmt(sqlite3_stmt *stmt,
        return;
 }
 
-static void _cal_db_instance_normal_get_projection_stmt(sqlite3_stmt *stmt,
+static void _cal_db_instance_utime_get_projection_stmt(sqlite3_stmt *stmt,
                const unsigned int *projection, const int projection_count,
                calendar_record_h record)
 {
@@ -568,5 +568,5 @@ static void _cal_db_instance_normal_get_projection_stmt(sqlite3_stmt *stmt,
        int stmt_count = 0;
 
        for (i = 0; i < projection_count; i++)
-               _cal_db_instance_normal_get_property_stmt(stmt, projection[i], &stmt_count, record);
+               _cal_db_instance_utime_get_property_stmt(stmt, projection[i], &stmt_count, record);
 }