Apply coding guide:calloc->calloc(), fail->Fail, move brace 87/46687/1
authorJeesun Kim <iamjs.kim@samsung.com>
Tue, 12 May 2015 05:31:01 +0000 (14:31 +0900)
committerJeesun Kim <iamjs.kim@samsung.com>
Tue, 25 Aug 2015 04:33:18 +0000 (13:33 +0900)
Change-Id: I18780b91cb367c5ce7c1782c69b425ccf48bafaf

54 files changed:
build-util/DB-schema-gen.c
client/cal_client_db_helper.c
common/cal_filter.c
common/cal_inotify.c
common/cal_internal.h
common/cal_list.c
common/cal_mutex.c
common/cal_query.c
common/cal_record.c
common/cal_record_alarm.c
common/cal_record_attendee.c
common/cal_record_calendar.c
common/cal_record_extended.c
common/cal_record_instance_allday.c
common/cal_record_instance_normal.c
common/cal_record_search.c
common/cal_record_timezone.c
common/cal_record_todo.c
common/cal_record_updated_info.c
common/cal_time.cpp
common/cal_typedef.h [changed mode: 0755->0644]
common/cal_vcalendar.c
common/cal_vcalendar_make.c
common/cal_vcalendar_parse.c
common/cal_view.c
common/ipc/cal_ipc_marshal.c
common/ipc/cal_ipc_marshal_search.c
native/cal_access_control.c
native/cal_db.c
native/cal_db_alarm.c
native/cal_db_calendar.c
native/cal_db_event.c
native/cal_db_extended.c
native/cal_db_instance.c
native/cal_db_plugin_alarm.c
native/cal_db_plugin_attendee.c
native/cal_db_plugin_calendar.c
native/cal_db_plugin_event.c
native/cal_db_plugin_extended.c
native/cal_db_plugin_instance_allday.c
native/cal_db_plugin_instance_allday_extended.c
native/cal_db_plugin_instance_normal.c
native/cal_db_plugin_instance_normal_extended.c
native/cal_db_plugin_search.c
native/cal_db_plugin_timezone.c
native/cal_db_plugin_todo.c
native/cal_db_query.c
native/cal_db_rrule.c
native/cal_db_util.c
server/cal_server_alarm.c
server/cal_server_calendar_delete.c
server/cal_server_contacts.c
server/cal_server_schema.c
server/cal_server_update.c

index c45cbb3..d3891b5 100755 (executable)
@@ -25,13 +25,12 @@ int main(int argc, char **argv)
        int c;
 
        fp = fopen(argv[1], "r");
-       if (fp == NULL)
+       if (NULL == fp)
                exit(EXIT_FAILURE);
 
        do{
                c = fgetc(fp);
-               switch (c)
-               {
+               switch (c) {
                case '\n':
                        printf("\\\n");
                        break;
@@ -49,7 +48,7 @@ int main(int argc, char **argv)
                        printf("%c",c);
                        break;
                }
-       }while(EOF != c);
+       }while (EOF != c);
 
        exit(EXIT_SUCCESS);
 }
index 9b3dbf2..db1c3ec 100644 (file)
@@ -73,7 +73,7 @@ do { \
                        timerclear(&__g_release_time); \
                } \
        } \
-} while(0)
+} while (0)
 
 #define CAL_LIMIT_ACCESS_BACK \
        do { \
@@ -81,7 +81,7 @@ do { \
                { \
                        gettimeofday(&__g_release_time, NULL); \
                } \
-       } while(0)
+       } while (0)
 
 
 static int __g_access_count;
@@ -103,7 +103,7 @@ int cal_client_db_insert_record(calendar_record_h record, int* id)
        // make indata
        indata = pims_ipc_data_create(0);
        if (indata == NULL) {
-               ERR("ipc data created fail !");
+               ERR("pims_ipc_data_create() Fail");
                return CALENDAR_ERROR_OUT_OF_MEMORY;
        }
 
@@ -330,7 +330,7 @@ int cal_client_db_replace_record(calendar_record_h record, int record_id)
 
        // make indata
        indata = pims_ipc_data_create(0);
-    RETVM_IF(indata == NULL, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
+    RETVM_IF(NULL == indata, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
 
        ret = cal_ipc_marshal_record(record,indata);
        if (CALENDAR_ERROR_NONE != ret) {
@@ -1033,7 +1033,7 @@ int cal_client_db_replace_records(calendar_list_h record_list, int *record_id_ar
 
        // make indata
        indata = pims_ipc_data_create(0);
-    RETVM_IF(indata == NULL, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
+    RETVM_IF(NULL == indata, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
 
        ret = cal_ipc_marshal_list(record_list,indata);
        if (CALENDAR_ERROR_NONE != ret) {
@@ -1293,7 +1293,7 @@ int cal_client_db_insert_vcalendars(const char* vcalendar_stream, int **record_i
 
        // make indata
        indata = pims_ipc_data_create(0);
-    RETVM_IF(indata == NULL, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
+    RETVM_IF(NULL == indata, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
 
        ret = cal_ipc_marshal_char(vcalendar_stream,indata);
        if (CALENDAR_ERROR_NONE != ret) {
@@ -1393,7 +1393,7 @@ int cal_client_db_replace_vcalendars(const char* vcalendar_stream, int *record_i
 
        // make indata
        indata = pims_ipc_data_create(0);
-    RETVM_IF(indata == NULL, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
+    RETVM_IF(NULL == indata, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
 
        ret = cal_ipc_marshal_char(vcalendar_stream,indata);
        if (CALENDAR_ERROR_NONE != ret) {
@@ -1487,7 +1487,7 @@ int cal_client_db_get_changes_exception_by_version(const char* view_uri, int ori
 
        // make indata
        indata = pims_ipc_data_create(0);
-    RETVM_IF(indata == NULL, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
+    RETVM_IF(NULL == indata, CALENDAR_ERROR_OUT_OF_MEMORY, "pims_ipc_data_create() Fail");
 
        ret = cal_ipc_marshal_char(view_uri,indata);
        if (CALENDAR_ERROR_NONE != ret) {
@@ -1558,9 +1558,8 @@ int cal_client_destroy(void)
 
        // make indata
        indata = pims_ipc_data_create(0);
-       if (indata == NULL)
-       {
-               ERR("ipc data created fail !");
+       if (NULL == indata) {
+               ERR("pims_ipc_data_create() Fail");
                ret = CALENDAR_ERROR_OUT_OF_MEMORY;
                return ret;
        }
index 9e47538..5416799 100644 (file)
@@ -257,17 +257,14 @@ static int _cal_filter_destroy_composite(cal_composite_filter_s* filter)
        GSList *cursor = NULL;
 
        RETV_IF(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
-       for(cursor=filter->filters;cursor;cursor=cursor->next)
-       {
+       for(cursor=filter->filters;cursor;cursor=cursor->next) {
                cal_filter_s *src = (cal_filter_s *)cursor->data;
-               if (src == NULL)
+               if (NULL == src)
                        continue;
-               if (src->filter_type == CAL_FILTER_COMPOSITE)
-               {
+               if (src->filter_type == CAL_FILTER_COMPOSITE) {
                        _cal_filter_destroy_composite((cal_composite_filter_s*)src);
                }
-               else
-               {
+               else {
                        _cal_filter_destroy_attribute((cal_attribute_filter_s*)src);
                }
 
@@ -284,8 +281,7 @@ static int _cal_filter_destroy_attribute(cal_attribute_filter_s* filter)
 {
        RETV_IF(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
 
-       if (filter->filter_type == CAL_FILTER_STR)
-       {
+       if (filter->filter_type == CAL_FILTER_STR) {
                CAL_FREE(filter->value.s);
        }
        CAL_FREE(filter);
@@ -304,30 +300,25 @@ static int _cal_filter_clone_composite(cal_composite_filter_s* filter,
        ret = calendar_filter_create(filter->view_uri, (calendar_filter_h *)&out);
        RETV_IF(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_OUT_OF_MEMORY);
 
-       for(cursor=filter->filters; cursor ; cursor=cursor->next)
-       {
+       for(cursor=filter->filters; cursor ; cursor=cursor->next) {
                cal_filter_s *src = (cal_filter_s *)cursor->data;
                cal_filter_s *dest = NULL;
 
-               if (src == NULL)
+               if (NULL == src)
                        continue;
 
-               if (src->filter_type == CAL_FILTER_COMPOSITE)
-               {
+               if (src->filter_type == CAL_FILTER_COMPOSITE) {
                        ret = _cal_filter_clone_composite((cal_composite_filter_s *)src,
                                        (cal_composite_filter_s **)&dest);
                }
-               else
-               {
+               else {
                        ret = _cal_filter_clone_attribute((cal_attribute_filter_s *)src,
                                        (cal_attribute_filter_s **)&dest);
                }
-               if (CALENDAR_ERROR_NONE == ret)
-               {
+               if (CALENDAR_ERROR_NONE == ret) {
                        out->filters = g_slist_append(out->filters, dest);
                }
-               else
-               {
+               else {
                        calendar_filter_destroy((calendar_filter_h)out);
                        return ret;
                }
@@ -349,8 +340,7 @@ static int _cal_filter_clone_attribute(cal_attribute_filter_s* filter,
        out->filter_type = filter->filter_type;
        out->match = filter->match;
        out->property_id = filter->property_id;
-       switch (filter->filter_type)
-       {
+       switch (filter->filter_type) {
        case CAL_FILTER_STR:
                out->value.s = SAFE_STRDUP(filter->value.s);
                break;
index 221dbdf..87b03d1 100644 (file)
@@ -184,16 +184,14 @@ static inline int _inotify_attach_handler(int fd)
        guint ret;
        GIOChannel *channel;
 
-       if (fd < 0)
-       {
+       if (fd < 0) {
                ERR("Invalid argument: fd is NULL");
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        channel = g_io_channel_unix_new(fd);
-       if (channel == NULL)
-       {
-               ERR("Failed to new channel");
+       if (NULL == channel) {
+               ERR("g_io_channel_unix_new() Fail");
                return -1; // CALENDAR_ERROR_FAILED_INOTIFY
        }
 
@@ -213,8 +211,7 @@ int cal_inotify_initialize(void)
        cal_mutex_lock(CAL_MUTEX_INOTIFY);
        calendar_inoti_count++;
 
-       if (1 < calendar_inoti_count)
-       {
+       if (1 < calendar_inoti_count) {
                DBG("inotify count =%d",calendar_inoti_count);
                cal_mutex_unlock(CAL_MUTEX_INOTIFY);
                return CALENDAR_ERROR_NONE;
@@ -223,10 +220,8 @@ int cal_inotify_initialize(void)
        cal_mutex_unlock(CAL_MUTEX_INOTIFY);
 #endif
        inoti_fd = inotify_init();
-
-       if (inoti_fd == -1)
-       {
-               ERR("Failed to init inotify(err:%d)", errno);
+       if (inoti_fd == -1) {
+               ERR("inotify_init() Fail(%d)", errno);
 #ifdef CAL_IPC_CLIENT
                cal_mutex_lock(CAL_MUTEX_INOTIFY);
                calendar_inoti_count = 0;
@@ -241,8 +236,7 @@ int cal_inotify_initialize(void)
        WARN_IF(ret < 0, "fcntl failed(%d)", ret);
 
        inoti_handler = _inotify_attach_handler(inoti_fd);
-       if (inoti_handler <= 0)
-       {
+       if (inoti_handler <= 0) {
                ERR("_inotify_attach_handler() Fail");
                close(inoti_fd);
                inoti_fd = -1;
@@ -503,8 +497,7 @@ void cal_inotify_finalize(void)
        cal_mutex_lock(CAL_MUTEX_INOTIFY);
        calendar_inoti_count--;
 
-       if (0 < calendar_inoti_count)
-       {
+       if (0 < calendar_inoti_count) {
                DBG("inotify count =%d",calendar_inoti_count);
                cal_mutex_unlock(CAL_MUTEX_INOTIFY);
                return ;
@@ -512,8 +505,7 @@ void cal_inotify_finalize(void)
        DBG("inotify count =%d",calendar_inoti_count);
        cal_mutex_unlock(CAL_MUTEX_INOTIFY);
 #endif
-       if (inoti_handler)
-       {
+       if (inoti_handler) {
                _cal_inotify_detach_handler(inoti_handler);
                inoti_handler = 0;
        }
@@ -525,8 +517,7 @@ void cal_inotify_finalize(void)
                noti_list = NULL;
        }
 
-       if (0 <= inoti_fd)
-       {
+       if (0 <= inoti_fd) {
                close(inoti_fd);
                inoti_fd = -1;
        }
index 54848a1..aa2198d 100644 (file)
                if (ptr) \
                free(ptr); \
                ptr = NULL; \
-       } while(0)
+       } while (0)
 
 
 // Thread-local storage
index fcce8a1..a998cd2 100644 (file)
 
 API int calendar_list_create(calendar_list_h* out_list)
 {
-       if (NULL == out_list)
-       {
-               ERR("Invalid parameter: list is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
-       cal_list_s *l;
+       cal_list_s *l = NULL;
+       RETV_IF(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = calloc(1, sizeof(cal_list_s));
-       if (l == NULL) {
-               ERR("calloc() Fail");
-               return CALENDAR_ERROR_OUT_OF_MEMORY;
-       }
+       RETVM_IF(NULL == l, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
 
        l->count = 0;
        l->record = NULL;
@@ -48,62 +41,40 @@ API int calendar_list_create(calendar_list_h* out_list)
 
 API int calendar_list_get_count(calendar_list_h list, int *count)
 {
-       cal_list_s *l;
+       cal_list_s *l = NULL;
 
-       if (list == NULL) {
-               ERR("Invalid argument: calendar_list_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
-       if (count == NULL) {
-               ERR("Invalid argument: count is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == count, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = (cal_list_s *)list;
-
        *count = l->count;
        return CALENDAR_ERROR_NONE;
 }
 
 API int calendar_list_add(calendar_list_h list, calendar_record_h record)
 {
-       cal_list_s *l;
+       cal_list_s *l = NULL;
 
-       if (list == NULL) {
-               ERR("Invalid argument: calendar_list_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
-       if (record == NULL) {
-               ERR("Invalid argument: calendar_record_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = (cal_list_s *)list;
 
        l->count++;
        l->record = g_list_append(l->record, record);
-       //l->cursor = g_list_nth(l->record, (l->count) -1);
-
        return CALENDAR_ERROR_NONE;
 }
 
 API int calendar_list_remove(calendar_list_h list, calendar_record_h record)
 {
-       GList *cursor;
-       cal_list_s *l;
+       cal_list_s *l = NULL;
 
-       if (list == NULL) {
-               ERR("Invalid argument: calendar_list_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
-       if (record == NULL) {
-               ERR("Invalid argument: calendar_record_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = (cal_list_s *)list;
 
-       cursor = l->record;
+       GList *cursor = l->record;
        while (cursor) {
                if (cursor->data == record) {
                        l->cursor = cursor->next;
@@ -118,74 +89,54 @@ API int calendar_list_remove(calendar_list_h list, calendar_record_h record)
 
 API int calendar_list_get_current_record_p(calendar_list_h list, calendar_record_h* record)
 {
-       cal_list_s *l;
+       cal_list_s *l = NULL;
 
-       if (list == NULL) {
-               ERR("Invalid argument: calendar_list_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
-       if (record == NULL) {
-               ERR("Invalid argument: calendar_record_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = (cal_list_s *)list;
-       if (l->cursor == NULL) {
+       if (NULL == l->cursor) {
                *record = NULL;
                return CALENDAR_ERROR_NO_DATA;
        }
 
        *record = l->cursor->data;
-
        return CALENDAR_ERROR_NONE;
 }
 
 API int calendar_list_prev(calendar_list_h list)
 {
-       cal_list_s *l;
+       cal_list_s *l = NULL;
 
-       if (list == NULL) {
-               ERR("Invalid argument: calendar_list_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = (cal_list_s *)list;
        l->cursor = g_list_previous(l->cursor);
-       if (l->cursor == NULL) {
-               DBG("No prev list");
+       if (NULL == l->cursor)
                return CALENDAR_ERROR_NO_DATA;
-       }
 
        return CALENDAR_ERROR_NONE;
 }
 
 API int calendar_list_next(calendar_list_h list)
 {
-       cal_list_s *l;
+       cal_list_s *l = NULL;
 
-       if (list == NULL) {
-               ERR("Invalid argument: calendar_list_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = (cal_list_s *)list;
        l->cursor = g_list_next(l->cursor);
-       if (l->cursor == NULL) {
-               //DBG("No next list");
+       if (NULL == l->cursor)
                return CALENDAR_ERROR_NO_DATA;
-       }
 
        return CALENDAR_ERROR_NONE;
 }
 
 API int calendar_list_first(calendar_list_h list)
 {
-       cal_list_s *l;
+       cal_list_s *l = NULL;
 
-       if (list == NULL) {
-               ERR("Invalid argument: calendar_list_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = (cal_list_s *)list;
        l->cursor = g_list_first(l->record);
@@ -195,12 +146,9 @@ API int calendar_list_first(calendar_list_h list)
 
 API int calendar_list_last(calendar_list_h list)
 {
-       cal_list_s *l;
+       cal_list_s *l = NULL;
 
-       if (list == NULL) {
-               ERR("Invalid argument: calendar_list_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = (cal_list_s *)list;
        l->cursor = g_list_last(l->record);
@@ -213,31 +161,23 @@ API int calendar_list_destroy(calendar_list_h list, bool delete_record)
        GList *cursor;
        cal_list_s *l = NULL;
 
-       if (list == NULL) {
-               ERR("Invalid argument: calendar_list_h is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
 
        l = (cal_list_s *)list;
 
-       if (delete_record == true)
-       {
+       if (delete_record == true) {
                cursor = l->record;
 
-               while (cursor)
-               {
+               while (cursor) {
                        if (cursor->data)
-                       {
                                calendar_record_destroy((calendar_record_h)(cursor->data), true);
-                       }
                        cursor = cursor->next;
                }
        }
        if (l->record)
-       {
                g_list_free(l->record);
-       }
-       CAL_FREE(l);
+
+       g_free(l);
 
        return CALENDAR_ERROR_NONE;
 }
@@ -248,68 +188,56 @@ int cal_list_clone(calendar_list_h list, calendar_list_h *out_list)
        int count = 0, i = 0;
        calendar_list_h l = NULL;
 
-       if (NULL == list || NULL == out_list)
-       {
-               ERR("Invalid parameter");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER);
 
        ret = calendar_list_get_count(list, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                return ret;
        }
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                return ret;
        }
 
        ret = calendar_list_create(&l);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                return ret;
        }
 
-       for(i = 0; i < count; i++)
-       {
+       for(i = 0; i < count; i++) {
                calendar_record_h record = NULL;
                calendar_record_h clone_record = NULL;
-               if (calendar_list_get_current_record_p(list,&record) != CALENDAR_ERROR_NONE)
-               {
+               if (calendar_list_get_current_record_p(list,&record) != CALENDAR_ERROR_NONE) {
                        ERR("calendar_list_get_count fail");
                        calendar_list_destroy(l, true);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
 
-               if (calendar_record_clone(record, &clone_record) != CALENDAR_ERROR_NONE)
-               {
-                       ERR("calendar_list_get_count fail");
+               if (calendar_record_clone(record, &clone_record) != CALENDAR_ERROR_NONE) {
+                       ERR("calendar_list_get_count Fail");
                        calendar_list_destroy(l, true);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
 
-               if (calendar_list_add(l, clone_record) != CALENDAR_ERROR_NONE)
-               {
-                       ERR("calendar_list_get_count fail");
+               if (calendar_list_add(l, clone_record) != CALENDAR_ERROR_NONE) {
+                       ERR("calendar_list_get_count Fail");
                        calendar_list_destroy(l, true);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
-
                calendar_list_next(list);
        }
 
        *out_list = l;
-
        return CALENDAR_ERROR_NONE;
 }
 
 int cal_list_get_nth_record_p(cal_list_s *list_s, int index, calendar_record_h *record)
 {
        RETV_IF(index < 0, CALENDAR_ERROR_INVALID_PARAMETER);
-
        RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
+
        *record = NULL;
 
        RETV_IF(NULL == list_s, CALENDAR_ERROR_INVALID_PARAMETER);
@@ -340,4 +268,3 @@ int cal_list_clear(cal_list_s *list_s)
        }
        return ret;
 }
-
index 8626b24..64e42fb 100644 (file)
@@ -68,8 +68,7 @@ void cal_mutex_lock(int type)
 
        mutex = _cal_mutex_get_mutex(type);
 
-       if (mutex != NULL)
-       {
+       if (mutex) {
                ret = pthread_mutex_lock(mutex);
                RETM_IF(ret, "mutex_lock Failed(%d)", ret);
        }
@@ -82,8 +81,7 @@ void cal_mutex_unlock(int type)
 
        mutex = _cal_mutex_get_mutex(type);
 
-       if (mutex != NULL)
-       {
+       if (mutex) {
                ret = pthread_mutex_unlock(mutex);
                RETM_IF(ret, "mutex_unlock Failed(%d)", ret);
        }
index 63d7dc8..a0d0792 100644 (file)
@@ -30,8 +30,7 @@ static bool _cal_query_property_check(const cal_property_info_s *properties,
 {
        int i;
 
-       for (i=0;i<count;i++)
-       {
+       for (i=0;i<count;i++) {
                cal_property_info_s *p = (cal_property_info_s*)&(properties[i]);
                if (property_id == p->property_id) {
                        return true;
@@ -69,8 +68,7 @@ API int calendar_query_set_projection(calendar_query_h query, unsigned int prope
 
        que = (cal_query_s *)query;
 
-       for (i=0;i<count;i++)
-       {
+       for (i=0;i<count;i++) {
                find = _cal_query_property_check(que->properties, que->property_count, property_ids[i]);
                RETVM_IF(false == find, CALENDAR_ERROR_INVALID_PARAMETER,
                                "Invalid parameter : property_id(%d) is not supported on view_uri(%s)", property_ids[i], que->view_uri);
@@ -113,8 +111,7 @@ API int calendar_query_set_filter(calendar_query_h query, calendar_filter_h filt
 
        que = (cal_query_s *)query;
 
-       if (((cal_composite_filter_s*)filter)->filters == NULL)
-       {
+       if (NULL == ((cal_composite_filter_s*)filter)->filters) {
                ERR("Empty filter");
                return CALENDAR_ERROR_NO_DATA;
        }
@@ -122,8 +119,7 @@ API int calendar_query_set_filter(calendar_query_h query, calendar_filter_h filt
        ret = cal_filter_clone(filter,&new_filter);
        RETV_IF(ret!=CALENDAR_ERROR_NONE, ret);
 
-       if (que->filter)
-       {
+       if (que->filter) {
                calendar_filter_destroy((calendar_filter_h)que->filter);
        }
 
@@ -158,8 +154,7 @@ API int calendar_query_destroy(calendar_query_h query)
        RETV_IF(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
        que = (cal_query_s *)query;
 
-       if (que->filter)
-       {
+       if (que->filter) {
                calendar_filter_destroy((calendar_filter_h)que->filter);
        }
 
@@ -184,13 +179,11 @@ int cal_query_clone(calendar_query_h query, calendar_query_h* out_query)
        RETV_IF(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_OUT_OF_MEMORY);
        out_que = (cal_query_s *)*out_query;
 
-       if (que->filter)
-       {
+       if (que->filter) {
                cal_filter_clone((calendar_filter_h)que->filter,(calendar_filter_h*)&out_filter);
        }
 
-       if (0 < que->projection_count)
-       {
+       if (0 < que->projection_count) {
                out_que->projection = calloc(que->projection_count, sizeof(unsigned int));
                RETVM_IF(NULL == out_que->projection, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
                memcpy(out_que->projection, que->projection , sizeof(unsigned int) * que->projection_count);
index 6f0e614..01b5a45 100644 (file)
@@ -50,8 +50,7 @@ extern cal_record_plugin_cb_s cal_record_extended_plugin_cb;
 
 cal_record_plugin_cb_s* cal_record_get_plugin_cb(cal_record_type_e type)
 {
-       switch (type)
-       {
+       switch (type) {
        case CAL_RECORD_TYPE_CALENDAR:
                return (&cal_record_calendar_plugin_cb);
        case CAL_RECORD_TYPE_EVENT:
@@ -91,24 +90,20 @@ static inline void _cal_record_set_property_flag(calendar_record_h record, unsig
        _record = (cal_record_s *)record;
        index = property_id & 0x00000FFF;
 
-       if (_record->properties_flags == NULL)
-       {
+       if (NULL == _record->properties_flags) {
                int count = 0;
                cal_view_get_property_info(_record->view_uri,&count);
 
-               if (0 < count)
-               {
+               if (0 < count) {
                        _record->properties_flags = calloc(count, sizeof(char));
                        _record->properties_max_count = count;
-                       if (_record->properties_flags == NULL)
-                       {
-                               ERR("calloc fail");
+                       if (NULL == _record->properties_flags) {
+                               ERR("calloc() Fail");
                                return ;
                        }
                }
-               else
-               {
-                       ERR("get property_info_fail");
+               else {
+                       ERR("get property_info_Fail");
                        return ;
                }
        }
@@ -125,18 +120,15 @@ bool cal_record_check_property_flag(calendar_record_h record, unsigned int prope
        _record = (cal_record_s *)record;
        index = property_id & 0x00000FFF;
 
-       if (_record->properties_flags == NULL)
-       {
+       if (NULL == _record->properties_flags) {
                if (flag == CAL_PROPERTY_FLAG_PROJECTION)
                        return true;
                else
                        return false;
        }
 
-       if (flag == CAL_PROPERTY_FLAG_PROJECTION)
-       {
-               if (_record->property_flag & CAL_PROPERTY_FLAG_PROJECTION)
-               {
+       if (flag == CAL_PROPERTY_FLAG_PROJECTION) {
+               if (_record->property_flag & CAL_PROPERTY_FLAG_PROJECTION) {
                        if (_record->properties_flags[index] & CAL_PROPERTY_FLAG_PROJECTION)
                                return true;
                        else
@@ -156,19 +148,18 @@ int cal_record_set_projection(calendar_record_h record, const unsigned int *proj
 
        cal_record_s *_record = NULL;
 
-       RETV_IF(record == NULL, -1);
+       RETV_IF(NULL == record, -1);
 
        _record = (cal_record_s *)record;
 
        CAL_FREE(_record->properties_flags);
        _record->properties_flags  = calloc(properties_max_count, sizeof(char));
 
-       RETVM_IF(NULL == _record->properties_flags, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+       RETVM_IF(NULL == _record->properties_flags, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
 
        _record->properties_max_count = properties_max_count;
 
-       for (i = 0; i < projection_count; i++)
-       {
+       for (i = 0; i < projection_count; i++) {
                _cal_record_set_property_flag(record, projection[i], CAL_PROPERTY_FLAG_PROJECTION);
        }
 
@@ -192,8 +183,7 @@ API int calendar_record_create(const char* view_uri, calendar_record_h* out_reco
 
        ret = plugin_cb->create(out_record);
 
-       if (CALENDAR_ERROR_NONE == ret)
-       {
+       if (CALENDAR_ERROR_NONE == ret) {
                CAL_RECORD_INIT_COMMON((cal_record_s*)*out_record, type, plugin_cb, cal_view_get_uri(view_uri));
        }
 
@@ -495,8 +485,7 @@ int cal_record_set_str(calendar_record_h record, unsigned int property_id, const
        RETVM_IF(false == cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
 
        ret = temp->plugin_cb->set_str(record, property_id, value);
-       if (CALENDAR_ERROR_NONE == ret)
-       {
+       if (CALENDAR_ERROR_NONE == ret) {
                _cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
        }
        return ret;
@@ -514,8 +503,7 @@ int cal_record_set_int(calendar_record_h record, unsigned int property_id, int v
        RETVM_IF(false == cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
 
        ret = temp->plugin_cb->set_int(record, property_id, value);
-       if (CALENDAR_ERROR_NONE == ret)
-       {
+       if (CALENDAR_ERROR_NONE == ret) {
                _cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
        }
        return ret;
@@ -533,8 +521,7 @@ int cal_record_set_double(calendar_record_h record, unsigned int property_id, do
        RETVM_IF(false == cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
 
        ret = temp->plugin_cb->set_double(record, property_id, value);
-       if (CALENDAR_ERROR_NONE == ret)
-       {
+       if (CALENDAR_ERROR_NONE == ret) {
                _cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
        }
        return ret;
@@ -552,8 +539,7 @@ int cal_record_set_lli(calendar_record_h record, unsigned int property_id, long
        RETVM_IF(false == cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
 
        ret = temp->plugin_cb->set_lli(record, property_id, value);
-       if (CALENDAR_ERROR_NONE == ret)
-       {
+       if (CALENDAR_ERROR_NONE == ret) {
                _cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
        }
        return ret;
@@ -571,8 +557,7 @@ int cal_record_set_caltime(calendar_record_h record, unsigned int property_id, c
        RETVM_IF(false == cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
 
        ret = temp->plugin_cb->set_caltime(record, property_id, value);
-       if (CALENDAR_ERROR_NONE == ret)
-       {
+       if (CALENDAR_ERROR_NONE == ret) {
                _cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
        }
        return ret;
index 7a6fa31..503d456 100644 (file)
@@ -128,8 +128,7 @@ static int _cal_record_alarm_clone(calendar_record_h record, calendar_record_h*
 static int _cal_record_alarm_get_str(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_alarm_s *rec = (cal_alarm_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ALARM_DESCRIPTION:
                *out_str = SAFE_STRDUP(rec->alarm_description);
                break;
@@ -150,8 +149,7 @@ static int _cal_record_alarm_get_str(calendar_record_h record, unsigned int prop
 static int _cal_record_alarm_get_str_p(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_alarm_s *rec = (cal_alarm_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ALARM_DESCRIPTION:
                *out_str = (rec->alarm_description);
                break;
@@ -172,8 +170,7 @@ static int _cal_record_alarm_get_str_p(calendar_record_h record, unsigned int pr
 static int _cal_record_alarm_get_int(calendar_record_h record, unsigned int property_id, int* out_value)
 {
        cal_alarm_s *rec = (cal_alarm_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ALARM_TICK:
                *out_value = (rec->remind_tick);
                break;
@@ -197,8 +194,7 @@ static int _cal_record_alarm_get_int(calendar_record_h record, unsigned int prop
 static int _cal_record_alarm_get_caltime(calendar_record_h record, unsigned int property_id, calendar_time_s* out_value)
 {
        cal_alarm_s *rec = (cal_alarm_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ALARM_ALARM:
                *out_value = rec->alarm;
                break;
@@ -212,8 +208,7 @@ static int _cal_record_alarm_get_caltime(calendar_record_h record, unsigned int
 static int _cal_record_alarm_set_str(calendar_record_h record, unsigned int property_id, const char* value)
 {
        cal_alarm_s *rec = (cal_alarm_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ALARM_DESCRIPTION:
                CAL_FREE(rec->alarm_description);
                rec->alarm_description = SAFE_STRDUP(value);
@@ -237,14 +232,12 @@ static int _cal_record_alarm_set_str(calendar_record_h record, unsigned int prop
 static int _cal_record_alarm_set_int(calendar_record_h record, unsigned int property_id, int value)
 {
        cal_alarm_s *rec = (cal_alarm_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ALARM_TICK:
                (rec->remind_tick)=value;
                break;
        case CAL_PROPERTY_ALARM_TICK_UNIT:
-               switch (value)
-               {
+               switch (value) {
                case CALENDAR_ALARM_NONE:
                case CALENDAR_ALARM_TIME_UNIT_SPECIFIC:
                case CALENDAR_ALARM_TIME_UNIT_MINUTE:
@@ -262,8 +255,7 @@ static int _cal_record_alarm_set_int(calendar_record_h record, unsigned int prop
                (rec->parent_id) = value;
                break;
        case CAL_PROPERTY_ALARM_ACTION:
-               switch (value)
-               {
+               switch (value) {
                case CALENDAR_ALARM_ACTION_AUDIO:
                case CALENDAR_ALARM_ACTION_DISPLAY:
                case CALENDAR_ALARM_ACTION_EMAIL:
@@ -285,8 +277,7 @@ static int _cal_record_alarm_set_int(calendar_record_h record, unsigned int prop
 static int _cal_record_alarm_set_caltime(calendar_record_h record, unsigned int property_id, calendar_time_s value)
 {
        cal_alarm_s *rec = (cal_alarm_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ALARM_ALARM:
                rec->alarm = value;
                break;
index 01633e2..90dd88c 100644 (file)
@@ -136,8 +136,7 @@ static int _cal_record_attendee_clone(calendar_record_h record, calendar_record_
 static int _cal_record_attendee_get_str(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_attendee_s *rec = (cal_attendee_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ATTENDEE_NUMBER:
                *out_str = SAFE_STRDUP(rec->attendee_number);
                break;
@@ -173,8 +172,7 @@ static int _cal_record_attendee_get_str(calendar_record_h record, unsigned int p
 static int _cal_record_attendee_get_str_p(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_attendee_s *rec = (cal_attendee_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ATTENDEE_NUMBER:
                *out_str = (rec->attendee_number);
                break;
@@ -210,8 +208,7 @@ static int _cal_record_attendee_get_str_p(calendar_record_h record, unsigned int
 static int _cal_record_attendee_get_int(calendar_record_h record, unsigned int property_id, int* out_value)
 {
        cal_attendee_s *rec = (cal_attendee_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ATTENDEE_CUTYPE:
                *out_value = (rec->attendee_cutype);
                break;
@@ -241,8 +238,7 @@ static int _cal_record_attendee_get_int(calendar_record_h record, unsigned int p
 static int _cal_record_attendee_set_str(calendar_record_h record, unsigned int property_id, const char* value)
 {
        cal_attendee_s *rec = (cal_attendee_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ATTENDEE_NUMBER:
                CAL_FREE(rec->attendee_number);
                rec->attendee_number = SAFE_STRDUP(value);
@@ -286,8 +282,7 @@ static int _cal_record_attendee_set_str(calendar_record_h record, unsigned int p
 static int _cal_record_attendee_set_int(calendar_record_h record, unsigned int property_id, int value)
 {
        cal_attendee_s *rec = (cal_attendee_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_ATTENDEE_CUTYPE:
                (rec->attendee_cutype) = value;
                break;
index f7a8d29..6869bb4 100644 (file)
@@ -145,8 +145,7 @@ static int _cal_record_calendar_clone(calendar_record_h record, calendar_record_
 static int _cal_record_calendar_get_str(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_calendar_s *cal_rec = (cal_calendar_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_CALENDAR_UID:
                *out_str = SAFE_STRDUP(cal_rec->uid);
                break;
@@ -185,8 +184,7 @@ static int _cal_record_calendar_get_str(calendar_record_h record, unsigned int p
 static int _cal_record_calendar_get_str_p(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_calendar_s *cal_rec = (cal_calendar_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_CALENDAR_UID:
                *out_str = (cal_rec->uid);
                break;
@@ -225,8 +223,7 @@ static int _cal_record_calendar_get_str_p(calendar_record_h record, unsigned int
 static int _cal_record_calendar_get_int(calendar_record_h record, unsigned int property_id, int* out_value)
 {
        cal_calendar_s *cal_rec = (cal_calendar_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_CALENDAR_ID:
                *out_value = (cal_rec->index);
                break;
@@ -256,8 +253,7 @@ static int _cal_record_calendar_get_int(calendar_record_h record, unsigned int p
 static int _cal_record_calendar_set_str(calendar_record_h record, unsigned int property_id, const char* value)
 {
        cal_calendar_s *cal_rec = (cal_calendar_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_CALENDAR_UID:
                CAL_FREE(cal_rec->uid);
                cal_rec->uid = SAFE_STRDUP(value);
index 11c2f74..8eac4bd 100644 (file)
@@ -122,8 +122,7 @@ static int _cal_record_extended_clone(calendar_record_h record, calendar_record_
 static int _cal_record_extended_get_str(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_extended_s *rec = (cal_extended_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_EXTENDED_KEY:
                *out_str = SAFE_STRDUP(rec->key);
                break;
@@ -141,8 +140,7 @@ static int _cal_record_extended_get_str(calendar_record_h record, unsigned int p
 static int _cal_record_extended_get_str_p(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_extended_s *rec = (cal_extended_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_EXTENDED_KEY:
                *out_str = (rec->key);
                break;
@@ -160,8 +158,7 @@ static int _cal_record_extended_get_str_p(calendar_record_h record, unsigned int
 static int _cal_record_extended_get_int(calendar_record_h record, unsigned int property_id, int* out_value)
 {
        cal_extended_s *rec = (cal_extended_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_EXTENDED_ID:
                *out_value = (rec->id);
                break;
@@ -182,8 +179,7 @@ static int _cal_record_extended_get_int(calendar_record_h record, unsigned int p
 static int _cal_record_extended_set_str(calendar_record_h record, unsigned int property_id, const char* value)
 {
        cal_extended_s *rec = (cal_extended_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_EXTENDED_KEY:
                CAL_FREE(rec->key);
                rec->key = SAFE_STRDUP(value);
@@ -203,8 +199,7 @@ static int _cal_record_extended_set_str(calendar_record_h record, unsigned int p
 static int _cal_record_extended_set_int(calendar_record_h record, unsigned int property_id, int value)
 {
        cal_extended_s *rec = (cal_extended_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_EXTENDED_ID:
                (rec->id) = value;
                break;
index c2dca17..c6039f5 100644 (file)
@@ -364,8 +364,7 @@ static int _cal_record_instance_allday_set_int(calendar_record_h record, unsigne
 static int _cal_record_instance_allday_set_double(calendar_record_h record, unsigned int property_id, double value)
 {
        cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE:
                (rec->latitude) = value;
                break;
index ea7c538..2fc36f8 100644 (file)
@@ -179,8 +179,7 @@ static int _cal_record_instance_normal_get_str(calendar_record_h record, unsigne
 static int _cal_record_instance_normal_get_str_p(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
                *out_str = (rec->summary);
                break;
@@ -262,8 +261,7 @@ static int _cal_record_instance_normal_get_double(calendar_record_h record, unsi
 static int _cal_record_instance_normal_get_lli(calendar_record_h record, unsigned int property_id, long long int* out_value)
 {
        cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME:
                *out_value = (rec->last_mod);
                break;
index b888e09..391c4f1 100644 (file)
@@ -83,11 +83,9 @@ static int _cal_record_search_destroy(calendar_record_h record, bool delete_chil
 
        cal_search_s *temp = (cal_search_s*)(record);
 
-       for(cursor = temp->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = temp->values;cursor;cursor=cursor->next) {
                cal_search_value_s *data = cursor->data;
-               if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
-               {
+               if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true) {
                        CAL_FREE(data->value.s);
                }
                CAL_FREE(data);
@@ -112,38 +110,30 @@ static int _cal_record_search_clone(calendar_record_h record, calendar_record_h*
 
        CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
 
-       for(cursor = src_data->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = src_data->values;cursor;cursor=cursor->next) {
                cal_search_value_s *src = cursor->data;
                cal_search_value_s *dest = calloc(1, sizeof(cal_search_value_s));
-               if (dest == NULL)
-               {
+               if (NULL == dest) {
                        CAL_FREE(out_data);
                        return CALENDAR_ERROR_OUT_OF_MEMORY;
                }
                dest->property_id = src->property_id;
-               if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
-               {
+               if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true) {
                        dest->value.s = SAFE_STRDUP(src->value.s);
                }
-               else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
-               {
+               else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true) {
                        dest->value.i = src->value.i;
                }
-               else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
-               {
+               else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
                        dest->value.d = src->value.d;
                }
-               else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
-               {
+               else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true) {
                        dest->value.lli = src->value.lli;
                }
-               else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
-               {
+               else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
                        dest->value.caltime = src->value.caltime;
                }
-               else
-               {
+               else {
 //                     ERR("invalid parameter (property:%d)",src->property_id);
                        CAL_FREE(dest);
                        continue;
@@ -162,18 +152,14 @@ static int _cal_record_search_get_str(calendar_record_h record, unsigned int pro
        cal_search_s *rec = (cal_search_s*)(record);
        GSList *cursor;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                cal_search_value_s *data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true) {
                                *out_str = SAFE_STRDUP(data->value.s);
                                break;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -188,18 +174,14 @@ static int _cal_record_search_get_str_p(calendar_record_h record, unsigned int p
        cal_search_s *rec = (cal_search_s*)(record);
        GSList *cursor;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                cal_search_value_s *data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true) {
                                *out_str = (data->value.s);
                                break;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -214,18 +196,14 @@ static int _cal_record_search_get_int(calendar_record_h record, unsigned int pro
        cal_search_s *rec = (cal_search_s*)(record);
        GSList *cursor;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                cal_search_value_s *data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true) {
                                *out_value = (data->value.i);
                                break;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -240,18 +218,14 @@ static int _cal_record_search_get_double(calendar_record_h record, unsigned int
        cal_search_s *rec = (cal_search_s*)(record);
        GSList *cursor;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                cal_search_value_s *data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
                                *out_value = (data->value.d);
                                break;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -266,18 +240,14 @@ static int _cal_record_search_get_lli(calendar_record_h record, unsigned int pro
        cal_search_s *rec = (cal_search_s*)(record);
        GSList *cursor;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                cal_search_value_s *data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true) {
                                *out_value = (data->value.lli);
                                break;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -292,18 +262,14 @@ static int _cal_record_search_get_caltime(calendar_record_h record, unsigned int
        cal_search_s *rec = (cal_search_s*)(record);
        GSList *cursor;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                cal_search_value_s *data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
                                *out_value = (data->value.caltime);
                                break;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -319,19 +285,15 @@ static int _cal_record_search_set_str(calendar_record_h record, unsigned int pro
        GSList *cursor;
        cal_search_value_s *data = NULL;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true) {
                                CAL_FREE(data->value.s);
                                (data->value.s) = SAFE_STRDUP(value);
                                return CALENDAR_ERROR_NONE;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -353,18 +315,14 @@ static int _cal_record_search_set_int(calendar_record_h record, unsigned int pro
        GSList *cursor;
        cal_search_value_s *data = NULL;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true) {
                                (data->value.i) = value;
                                return CALENDAR_ERROR_NONE;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -386,18 +344,14 @@ static int _cal_record_search_set_double(calendar_record_h record, unsigned int
        GSList *cursor;
        cal_search_value_s *data = NULL;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
                                (data->value.d) = value;
                                return CALENDAR_ERROR_NONE;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -419,18 +373,14 @@ static int _cal_record_search_set_lli(calendar_record_h record, unsigned int pro
        GSList *cursor;
        cal_search_value_s *data = NULL;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true) {
                                (data->value.lli) = value;
                                return CALENDAR_ERROR_NONE;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
@@ -452,18 +402,14 @@ static int _cal_record_search_set_caltime(calendar_record_h record, unsigned int
        GSList *cursor;
        cal_search_value_s *data = NULL;
 
-       for(cursor = rec->values;cursor;cursor=cursor->next)
-       {
+       for(cursor = rec->values;cursor;cursor=cursor->next) {
                data = cursor->data;
-               if (data->property_id == property_id)
-               {
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
-                       {
+               if (data->property_id == property_id) {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
                                (data->value.caltime) = value;
                                return CALENDAR_ERROR_NONE;
                        }
-                       else
-                       {
+                       else {
                                ERR("invalid parameter (property:%d)",data->property_id);
                                return CALENDAR_ERROR_INVALID_PARAMETER;
                        }
index 9e0e102..1ec3558 100644 (file)
@@ -133,8 +133,7 @@ static int _cal_record_timezone_clone(calendar_record_h record, calendar_record_
 static int _cal_record_timezone_get_str(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_timezone_s *rec = (cal_timezone_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_TIMEZONE_STANDARD_NAME:
                *out_str = SAFE_STRDUP(rec->standard_name);
                break;
@@ -152,8 +151,7 @@ static int _cal_record_timezone_get_str(calendar_record_h record, unsigned int p
 static int _cal_record_timezone_get_str_p(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_timezone_s *rec = (cal_timezone_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_TIMEZONE_STANDARD_NAME:
                *out_str = (rec->standard_name);
                break;
@@ -171,8 +169,7 @@ static int _cal_record_timezone_get_str_p(calendar_record_h record, unsigned int
 static int _cal_record_timezone_get_int(calendar_record_h record, unsigned int property_id, int* out_value)
 {
        cal_timezone_s *rec = (cal_timezone_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_TIMEZONE_ID:
                *out_value = (rec->index);
                break;
@@ -223,8 +220,7 @@ static int _cal_record_timezone_get_int(calendar_record_h record, unsigned int p
 static int _cal_record_timezone_set_str(calendar_record_h record, unsigned int property_id, const char* value)
 {
        cal_timezone_s *rec = (cal_timezone_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_TIMEZONE_STANDARD_NAME:
                CAL_FREE(rec->standard_name);
                rec->standard_name = SAFE_STRDUP(value);
@@ -244,8 +240,7 @@ static int _cal_record_timezone_set_str(calendar_record_h record, unsigned int p
 static int _cal_record_timezone_set_int(calendar_record_h record, unsigned int property_id, int value)
 {
        cal_timezone_s *rec = (cal_timezone_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_TIMEZONE_ID:
                (rec->index) = value;
                break;
index d234843..d6e40a2 100644 (file)
@@ -317,8 +317,7 @@ static int _cal_record_todo_get_str(calendar_record_h record, unsigned int prope
 static int _cal_record_todo_get_str_p(calendar_record_h record, unsigned int property_id, char** out_str)
 {
        cal_todo_s *rec = (cal_todo_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_TODO_SUMMARY:
                *out_str = (rec->summary);
                break;
index a9dafbc..f2eae08 100644 (file)
@@ -104,8 +104,7 @@ static int _cal_record_updated_info_get_int(calendar_record_h record, unsigned i
 {
        cal_updated_info_s *rec = (cal_updated_info_s*)(record);
 
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_UPDATED_INFO_ID:
                *out_value = (rec->id);
                break;
@@ -129,8 +128,7 @@ static int _cal_record_updated_info_get_int(calendar_record_h record, unsigned i
 static int _cal_record_updated_info_set_int(calendar_record_h record, unsigned int property_id, int value)
 {
        cal_updated_info_s *rec = (cal_updated_info_s*)(record);
-       switch (property_id)
-       {
+       switch (property_id) {
        case CAL_PROPERTY_UPDATED_INFO_ID:
                (rec->id) = value;
                break;
index 4767b6c..510ad6a 100644 (file)
@@ -53,8 +53,7 @@ int cal_time_is_registered_tzid(const char *tzid)
        int i;
        UErrorCode ec = U_ZERO_ERROR;
 
-       if (NULL == tzid)
-       {
+       if (NULL == tzid) {
                ERR("tzid is NULL");
                return false;
        }
@@ -62,13 +61,11 @@ int cal_time_is_registered_tzid(const char *tzid)
        StringEnumeration* s = TimeZone::createEnumeration();
        int32_t s_count = s->count(ec);
 
-       for (i = 0; i < s_count; i++)
-       {
+       for (i = 0; i < s_count; i++) {
                char buf[128] = {0};
                const UnicodeString *unicode_tzid = s->snext(ec);
                unicode_tzid->extract(buf, sizeof(buf), NULL, ec);
-               if (CAL_STRING_EQUAL == strncmp(tzid, buf, strlen(buf)))
-               {
+               if (CAL_STRING_EQUAL == strncmp(tzid, buf, strlen(buf))) {
                        is_found = true;
                        break;
                }
@@ -209,11 +206,7 @@ static int _cal_time_get_like_utzid(UChar *utzid, int len, const char *tzid, cal
        int gmtoffset;
        UErrorCode ec = U_ZERO_ERROR;
 
-       if (NULL == timezone)
-       {
-               ERR("Invalid parameter: timezone is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == timezone, CALENDAR_ERROR_INVALID_PARAMETER);
 
        // make utzid
        UnicodeString zoneStrID;
@@ -224,8 +217,7 @@ static int _cal_time_get_like_utzid(UChar *utzid, int len, const char *tzid, cal
        cal_timezone_s *tz = (cal_timezone_s *)timezone;
        gmtoffset = sec2ms(tz->tz_offset_from_gmt * 60);
 
-       if (tz->day_light_bias == 0)
-       {
+       if (tz->day_light_bias == 0) {
                char buf[128] = {0};
                snprintf(buf, sizeof(buf), "Etc/GMT%c%d",
                                gmtoffset < 0 ? '+' : '-',
@@ -258,8 +250,8 @@ static int _cal_time_get_like_utzid(UChar *utzid, int len, const char *tzid, cal
        int32_t stzdstoff[4];
        stzudate[0] = now;
        DBG("tzid[%s]", tzid);
-       for (i = 0; i < 4; i++) // get 4 date: dst begin & end, std begin & end
-       {
+       for (i = 0; i < 4; i++) {
+               // get 4 date: dst begin & end, std begin & end
                stz->getPreviousTransition(stzudate[i], (UBool)false, trans);
                stz->getOffset(stzudate[i], (UBool)true, stzrawoff[i], stzdstoff[i], ec);
                stzudate[i +1] = trans.getTime();
@@ -279,34 +271,26 @@ static int _cal_time_get_like_utzid(UChar *utzid, int len, const char *tzid, cal
        s_count = s->count(ec);
 
        DBG("Has count(%d) with the same gmtoffset(%d)", s_count, gmtoffset);
-       if (s_count == 0)
-       {
-               DBG("No count matched");
-               return -1;
-       }
+       RETVM_IF(0 == s_count, -1, "No count matched");
 
-       for (i = 0; i < s_count; i++)
-       {
+       for (i = 0; i < s_count; i++) {
                const UnicodeString *unicode_tzid = s->snext(ec);
                TimeZone *_timezone = TimeZone::createTimeZone(*unicode_tzid);
 
-               if (_timezone->getDSTSavings() != (gmtoffset))
-               {
+               if (_timezone->getDSTSavings() != (gmtoffset)) {
                        delete _timezone;
                        continue;
                }
 
                RuleBasedTimeZone *rule = (RuleBasedTimeZone *)_timezone;
                udate = now;
-               for (j = 0; j < 4; j++)
-               {
+               for (j = 0; j < 4; j++) {
                        rule->getPreviousTransition(udate, (UBool)false, trans);
                        rule->getOffset(udate, (UBool)true, rawoff, dstoff, ec);
                        udate = trans.getTime();
                        DBG("(%lld)(%d)(%d)", ms2sec(udate), rawoff, dstoff);
 
-                       if (udate == stzudate[i+1] && rawoff == stzrawoff[i] && dstoff == stzdstoff[i])
-                       {
+                       if (udate == stzudate[i+1] && rawoff == stzrawoff[i] && dstoff == stzdstoff[i]) {
                                DBG("Found matched");
                                is_found = 1;
                                break;
@@ -321,8 +305,7 @@ static int _cal_time_get_like_utzid(UChar *utzid, int len, const char *tzid, cal
                                delete s;
                                return CALENDAR_ERROR_OUT_OF_MEMORY;
                        }
-                       for (i = 0; i < unicode_tzid->length(); i++)
-                       {
+                       for (i = 0; i < unicode_tzid->length(); i++) {
                                _like_tzid[i] = unicode_tzid->charAt(i);
                        }
                        DBG("Found and set like tzid[%s]", _like_tzid);
@@ -347,8 +330,7 @@ UCalendar *cal_time_open_ucal(int calendar_system_type, const char *tzid, int wk
 
        char localeBuf[ULOC_LOCALE_IDENTIFIER_CAPACITY] = {0};
 
-       switch (calendar_system_type)
-       {
+       switch (calendar_system_type) {
        case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
                uloc_setKeywordValue("calendar", "chinese", localeBuf, ULOC_LOCALE_IDENTIFIER_CAPACITY, &status);
                ucal = ucal_open(utf16_timezone, -1, localeBuf, UCAL_TRADITIONAL, &status);
@@ -364,8 +346,7 @@ UCalendar *cal_time_open_ucal(int calendar_system_type, const char *tzid, int wk
                return NULL;
        }
 
-       if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY)
-       {
+       if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY) {
                DBG("set wkst(%d)", wkst);
                ucal_setAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK, wkst);
        }
@@ -386,8 +367,8 @@ UCalendar *cal_time_get_ucal(const char *tzid, int wkst)
                return NULL;
        }
 
-       if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY)
-       {
+       if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY) {
+               DBG("set wkst(%d)", wkst);
                ucal_setAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK, wkst);
        }
 
@@ -399,30 +380,21 @@ int cal_time_get_like_tzid(const char *tzid, calendar_record_h timezone, char **
        int ret = CALENDAR_ERROR_NONE;
        UChar *utzid = NULL;
 
-       if (NULL == timezone)
-       {
-               ERR("Invalid parameter: timezone is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == timezone, CALENDAR_ERROR_INVALID_PARAMETER);
 
-       if (tzid == NULL)
-       {
+       if (NULL == tzid) {
                DBG("tzid is NULL so set gmt");
                tzid = CAL_TZID_GMT;
        }
 
        utzid = (UChar *)calloc(strlen(tzid) + 1, sizeof(UChar));
-       if (utzid == NULL)
-       {
-               ERR("calloc() Fail");
-               return CALENDAR_ERROR_DB_FAILED;
-       }
+       RETVM_IF(NULL == utzid, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
+
        u_uastrcpy(utzid, tzid);
 
        ret = _cal_time_get_like_utzid(utzid, u_strlen(utzid), tzid, timezone, like_tzid);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               DBG("Failed to find from timezone table, so set GMT");
+       if (CALENDAR_ERROR_NONE != ret) {
+               DBG("_cal_time_get_like_utzid() Fail(%d): set GMT", ret);
                *like_tzid = strdup(CAL_TZID_GMT);
        }
        CAL_FREE(utzid);
@@ -434,8 +406,7 @@ void cal_time_set_caltime(UCalendar *ucal, calendar_time_s *ct)
 {
        UErrorCode status = U_ZERO_ERROR;
 
-       switch (ct->type)
-       {
+       switch (ct->type) {
        case CALENDAR_TIME_UTIME:
                ucal_setMillis(ucal, sec2ms(ct->time.utime), &status);
                RETM_IF(U_FAILURE(status), "ucal_setMillis() failed(%s)",
@@ -475,8 +446,7 @@ char* cal_time_extract_by(int calendar_system_type, const char *tzid, int wkst,
        }
        cal_time_set_caltime(ucal, ct);
 
-       switch (field)
-       {
+       switch (field) {
        case CAL_MONTH:
                vali = ucal_get(ucal, UCAL_MONTH, &status) + 1;
                snprintf(buf, sizeof(buf), "%d", vali);
@@ -507,8 +477,7 @@ char* cal_time_convert_ltos(const char *tzid, long long int lli, int is_allday)
        UCalendar *ucal;
        UErrorCode status = U_ZERO_ERROR;
 
-       if (tzid == NULL)
-       {
+       if (NULL == tzid) {
                DBG("tzid is NULL so set gmt");
                tzid = CAL_TZID_GMT;
        }
@@ -528,13 +497,11 @@ char* cal_time_convert_ltos(const char *tzid, long long int lli, int is_allday)
        min = ucal_get(ucal, UCAL_MINUTE, &status);
        s = ucal_get(ucal, UCAL_SECOND, &status);
 
-       if (CAL_STRING_EQUAL == strncmp(tzid, CAL_TZID_GMT, strlen(CAL_TZID_GMT)))
-       {
+       if (CAL_STRING_EQUAL == strncmp(tzid, CAL_TZID_GMT, strlen(CAL_TZID_GMT))) {
                snprintf(buf, sizeof(buf), "%04d%02d%02dT%02d%02d%02d%s", y, mon, d, h, min, s,
                                is_allday ? "" : "Z");
        }
-       else
-       {
+       else {
                snprintf(buf, sizeof(buf), "%04d%02d%02dT%02d%02d%02d", y, mon, d, h, min, s);
        }
 
@@ -587,7 +554,7 @@ long long int cal_time_convert_stol(char *tzid, char *datetime)
        int y, mon, d, h, min, s;
        char t, z;
 
-       if (datetime == NULL || strlen(datetime) == 0) {
+       if (NULL == datetime || '\0' == *datetime) {
                ERR("Invalid argument");
                return -1;
        }
@@ -627,8 +594,7 @@ int cal_time_ltoi2(char *tzid, long long int lli, int *nth, int *wday)
        ucal_setMillis(ucal, sec2ms(lli), &status);
 
        if (wday)  *wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &status);
-       if (nth)
-       {
+       if (nth) {
                int temp = 0;
                int temp2 = 0;
                temp = ucal_get(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, &status);
@@ -649,10 +615,8 @@ long long int cal_time_get_now(void)
 
 int cal_time_get_next_date(calendar_time_s *today, calendar_time_s *next)
 {
-       if (NULL == today || NULL == next)
-       {
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
+       RETV_IF(NULL == today, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == next, CALENDAR_ERROR_INVALID_PARAMETER);
 
        UCalendar *ucal = NULL;
        UErrorCode status = U_ZERO_ERROR;
@@ -660,11 +624,8 @@ int cal_time_get_next_date(calendar_time_s *today, calendar_time_s *next)
        const char *tzid = CAL_TZID_GMT;
 
        utzid = (UChar *)calloc(strlen(tzid) + 1, sizeof(UChar));
-       if (utzid == NULL)
-       {
-               ERR("calloc() Fail");
-               return CALENDAR_ERROR_OUT_OF_MEMORY;
-       }
+       RETVM_IF(NULL == utzid, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
+
        u_uastrcpy(utzid, tzid);
        ucal = ucal_open(utzid, u_strlen(utzid), "en_US", UCAL_TRADITIONAL, &status);
        if (U_FAILURE(status)) {
@@ -673,8 +634,7 @@ int cal_time_get_next_date(calendar_time_s *today, calendar_time_s *next)
                return status;
        }
 
-       switch (today->type)
-       {
+       switch (today->type) {
        case CALENDAR_TIME_UTIME:
 
                break;
@@ -712,13 +672,8 @@ int cal_time_get_next_date(calendar_time_s *today, calendar_time_s *next)
 int cal_time_get_next_time(UCalendar *ucal, int offset, int freq, calendar_time_s *next)
 {
        UErrorCode status = U_ZERO_ERROR;
-       if (NULL == next)
-       {
-               ERR("Invalid parameter: next is NULL");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-       }
-       switch (next->type)
-       {
+       RETV_IF(NULL == next, CALENDAR_ERROR_INVALID_PARAMETER);
+       switch (next->type) {
        case CALENDAR_TIME_UTIME:
                ucal_setMillis(ucal, sec2ms(next->time.utime), &status);
                break;
@@ -736,8 +691,7 @@ int cal_time_get_next_time(UCalendar *ucal, int offset, int freq, calendar_time_
        }
 
        UCalendarDateFields unit = UCAL_DATE;
-       switch (freq)
-       {
+       switch (freq) {
        case CALENDAR_RECURRENCE_YEARLY:
                DBG("CALENDAR_RECURRENCE_YEARLY:");
                unit = UCAL_YEAR;
@@ -760,8 +714,7 @@ int cal_time_get_next_time(UCalendar *ucal, int offset, int freq, calendar_time_
        }
        ucal_add(ucal, unit, offset, &status);
 
-       switch (next->type)
-       {
+       switch (next->type) {
        case CALENDAR_TIME_UTIME:
                next->time.utime = ms2sec(ucal_getMillis(ucal, &status));
                DBG("next utime(%lld)", next->time.utime);
@@ -790,11 +743,8 @@ char* cal_time_get_timezone(void)
 {
        char buf[256] = {0};
        ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf)-1);
-       if (-1 == len)
-       {
-               ERR("readlink() failed");
-               return NULL;
-       }
+       RETVM_IF(-1 == len, NULL, "readlink() Fail");
+
        buf[len] = '\0';
        return g_strdup(buf + strlen("/usr/share/zoneinfo/"));
 }
@@ -802,8 +752,7 @@ char* cal_time_get_timezone(void)
 long long int cal_time_get_utime(UCalendar *ucal, int y, int mon, int d, int h, int min, int s)
 {
        UErrorCode status = U_ZERO_ERROR;
-       if (ucal)
-       {
+       if (ucal) {
                ucal_set(ucal, UCAL_YEAR, y);
                ucal_set(ucal, UCAL_MONTH, mon -1);
                ucal_set(ucal, UCAL_DATE, d);
@@ -915,8 +864,7 @@ void cal_time_modify_caltime(calendar_time_s *caltime, long long int diff)
 
        UCalendar *ucal = __get_gmt_ucal();
        long long int lli = 0;
-       switch (caltime->type)
-       {
+       switch (caltime->type) {
        case CALENDAR_TIME_UTIME:
                DBG("Before (%lld)", caltime->time.utime);
                caltime->time.utime += diff;
old mode 100755 (executable)
new mode 100644 (file)
index f14912b..2ae5128
@@ -493,14 +493,14 @@ typedef struct  {
 #define CAL_CALTIME_SET_UTIME(dest, src_utime) do {\
        (dest).type = CALENDAR_TIME_UTIME; \
        (dest).time.utime = src_utime; \
-} while(0)
+} while (0)
 
 #define CAL_CALTIME_SET_DATE(dest, src_year, src_month, src_mday) do {\
        (dest).type = CALENDAR_TIME_LOCALTIME; \
        (dest).time.date.year = src_year; \
        (dest).time.date.month = src_month; \
        (dest).time.date.mday = src_mday; \
-} while(0)
+} while (0)
 
 typedef struct {
        int property_id;
index 4ede866..0691161 100644 (file)
@@ -42,8 +42,8 @@ API int calendar_vcalendar_make_from_records(calendar_list_h list, char **vcalen
        cal_make_s *b;
        char *ical = NULL;
 
-       RETV_IF(list == NULL, CALENDAR_ERROR_INVALID_PARAMETER);
-       RETV_IF(vcalendar_stream == NULL, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER);
 
        b = cal_vcalendar_make_new();
        RETVM_IF(!b, CALENDAR_ERROR_OUT_OF_MEMORY,
@@ -193,7 +193,7 @@ API int calendar_vcalendar_parse_to_calendar_foreach(const char *vcalendar_file_
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
        file = fopen(vcalendar_file_path, "r");
-       if (file == NULL) {
+       if (NULL == file) {
                ERR("Invalid argument: no file");
                calendar_list_destroy(list, true);
                return CALENDAR_ERROR_INVALID_PARAMETER;
index 638a36b..71198c1 100644 (file)
@@ -214,11 +214,9 @@ static int  _cal_vcalendar_make_time(cal_make_s *b, char *tzid, calendar_time_s
        char buf[256] = {0};
        int y = 0, m = 0, d = 0;
        int h = 0, n = 0, s = 0;
-       switch (b->version)
-       {
+       switch (b->version) {
        case VCAL_VER_1:
-               switch (t->type)
-               {
+               switch (t->type) {
                case CALENDAR_TIME_UTIME:
                        cal_time_get_local_datetime(NULL, t->time.utime, &y, &m, &d, &h, &n, &s);
                        snprintf(buf, sizeof(buf), ":"VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
@@ -231,8 +229,7 @@ static int  _cal_vcalendar_make_time(cal_make_s *b, char *tzid, calendar_time_s
                }
                break;
        case VCAL_VER_2:
-               switch (t->type)
-               {
+               switch (t->type) {
                case CALENDAR_TIME_UTIME:
                        if (NULL == tzid || '\0' == *tzid) {
                                cal_time_get_local_datetime(NULL, t->time.utime, &y, &m, &d, &h, &n, &s);
@@ -267,8 +264,7 @@ static void __encode_escaped_char(char *p, char **r)
        DBG("Before [%s]", p);
        while ('\0' != *p) {
                if ('\r' == *p && '\n' == *(p + 1)) break;
-               switch (*p)
-               {
+               switch (*p) {
                case '\n':
                        *q = '\\';
                        *(q +1) = 'n';
@@ -379,7 +375,7 @@ static void _cal_vcalendar_make_aalarm(cal_make_s *b, calendar_record_h record,
 {
        RETM_IF(NULL == b, "b is NULL");
        RETM_IF(NULL == record, "record is NULL");
-       RETM_IF(alarm == NULL, "alarm is NULL");
+       RETM_IF(NULL == alarm, "alarm is NULL");
 
        int ret = CALENDAR_ERROR_NONE;
 
@@ -470,8 +466,7 @@ static void _cal_vcalendar_make_alarm(cal_make_s *b, calendar_record_h alarm)
        int action = 0;
        ret = calendar_record_get_int(alarm, _calendar_alarm.action, &action);
        RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
-       switch (action)
-       {
+       switch (action) {
        default:
        case CALENDAR_ALARM_ACTION_AUDIO:
                ret = _cal_vcalendar_make_printf(b, "ACTION:", "AUDIO");
@@ -521,8 +516,7 @@ int _cal_vcalendar_make_rrule_append_mday(char *buf, int buf_len, char *mday)
        }
        int len = strlen(buf);
        length = g_strv_length(t);
-       for (i = 0; i < length; i++)
-       {
+       for (i = 0; i < length; i++) {
                if (*t[i] == '\0')
                        continue;
 
@@ -571,9 +565,8 @@ static void _cal_vcalendar_make_rrule_append_setpos(calendar_record_h record, ch
                // in ver2.0, 3TH should be changed to setpos:3, byday:TH
                char *byday = NULL;
                ret = calendar_record_get_str_p(record, _calendar_event.byday, &byday);
-               RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() failed(%d)", ret);
-               if (NULL == byday || '\0' == byday[0])
-               {
+               RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
+               if (NULL == byday || '\0' == byday[0]) {
                        blen += snprintf(buf +blen, buf_len -blen, "%s", "1+ ");
                        return;
                }
@@ -635,8 +628,7 @@ void _cal_vcalendar_make_rrule_append_text_wday(int rrule_type, char *buf, int b
                return;
        }
        length = g_strv_length(t);
-       for (i = 0; i < length; i++)
-       {
+       for (i = 0; i < length; i++) {
                if (*t[i] == '\0')
                        continue;
 
@@ -695,8 +687,7 @@ int _cal_vcalendar_make_rrule_append_wday(int rrule_type, char *buf, int buf_len
        length = g_strv_length(t);
        DBG("len(%d)", length);
 
-       for (i = 0; i < length; i++)
-       {
+       for (i = 0; i < length; i++) {
                if (*t[i] == '\0') continue;
 
                p = t[i];
@@ -704,30 +695,23 @@ int _cal_vcalendar_make_rrule_append_wday(int rrule_type, char *buf, int buf_len
                while (p[j] == '+' || p[j] == '-' || ('1' <= p[j] && p[j] <= '9'))
                        j++;
 
-               if (0 < j)
-               {
-                       if (CALENDAR_RECURRENCE_WEEKLY == rrule_type)
-                       {
+               if (0 < j) {
+                       if (CALENDAR_RECURRENCE_WEEKLY == rrule_type) {
                                num_past = num;
                        }
-                       else
-                       {
-                               if (*p == '-')
-                               {
+                       else {
+                               if (*p == '-') {
                                        snprintf(buf_temp, j + 1, "%s", p + 1);
                                        num = atoi(buf_temp);
-                                       if (0 == i)
-                                       {
+                                       if (0 == i) {
                                                num_past = num;
                                                len += snprintf(buf +len, buf_len -len, "%s- ", buf_temp);
                                        }
                                }
-                               else
-                               {
+                               else {
                                        snprintf(buf_temp, j + 1, "%s", p);
                                        num = atoi(buf_temp);
-                                       if (0 == i)
-                                       {
+                                       if (0 == i) {
                                                num_past = num;
                                                len += snprintf(buf +len, buf_len -len, "%s+ ", buf_temp);
                                        }
@@ -755,8 +739,7 @@ static void __make_begin(cal_make_s *b, calendar_record_h record)
        RET_IF(NULL == record);
 
        int ret = 0;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = _cal_vcalendar_make_printf(b, "BEGIN:VEVENT", NULL);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "_cal_vcalendar_make_printf() Fail(%d)", ret);
@@ -776,8 +759,7 @@ static void __make_dtstart(cal_make_s *b, calendar_record_h record)
        int ret = 0;
        char *tzid = NULL;
        calendar_time_s ct = {0};
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_str_p(record, _calendar_event.start_tzid, &tzid);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
@@ -804,8 +786,7 @@ static void __make_dtend(cal_make_s *b, calendar_record_h record)
        int ret = 0;
        char *tzid = NULL;
        calendar_time_s ct = {0};
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_str_p(record, _calendar_event.end_tzid, &tzid);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
@@ -834,8 +815,7 @@ static void __make_sensitivity(cal_make_s *b, calendar_record_h record)
 
        int ret = 0;
        int value = 0;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_int(record, _calendar_event.sensitivity, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
@@ -846,8 +826,7 @@ static void __make_sensitivity(cal_make_s *b, calendar_record_h record)
                break;
        }
        char *sensitivity = NULL;
-       switch (value)
-       {
+       switch (value) {
        case CALENDAR_SENSITIVITY_PUBLIC:
                sensitivity = "PUBLIC";
                break;
@@ -873,20 +852,17 @@ int _cal_vcalendar_make_rrule_append_until(char *buf, int buf_len, calendar_reco
        calendar_time_s caltime;
 
        ret = calendar_record_get_int(record, _calendar_event.range_type, &range_type);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("calendar_record_get_int() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("calendar_record_get_int() Fail");
                return ret;
        }
 
        int len = strlen(buf);
-       switch (range_type)
-       {
+       switch (range_type) {
        case CALENDAR_RANGE_COUNT:
                ret = calendar_record_get_int(record, _calendar_event.count, &count);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
-                       ERR("calendar_record_get_int() failed");
+               if (CALENDAR_ERROR_NONE != ret) {
+                       ERR("calendar_record_get_int() Fail");
                        return ret;
                }
                snprintf(buf +len, buf_len -len, "#%d", count);
@@ -896,13 +872,11 @@ int _cal_vcalendar_make_rrule_append_until(char *buf, int buf_len, calendar_reco
                memset(&caltime, 0x0, sizeof(calendar_time_s));
 
                ret = calendar_record_get_caltime(record, _calendar_event.until_time, &caltime);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
-                       ERR("calendar_record_get_caltime() failed");
+               if (CALENDAR_ERROR_NONE != ret) {
+                       ERR("calendar_record_get_caltime() Fail");
                        return ret;
                }
-               switch (caltime.type)
-               {
+               switch (caltime.type) {
                case CALENDAR_TIME_UTIME:
                        until_str = cal_time_convert_ltos(NULL, caltime.time.utime, 0);
                        snprintf(buf +len, buf_len -len, "%s", until_str);
@@ -932,8 +906,7 @@ static void __make_rrule_ver1_default(calendar_record_h record, int freq, int in
        ret = calendar_record_get_caltime(record, _calendar_event.start_time, &caltime);
        WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() Fail(%d)", ret);
 
-       switch (freq)
-       {
+       switch (freq) {
        case CALENDAR_RECURRENCE_YEARLY:
                snprintf(buf, buf_size, "YD%d ", interval);
                break;
@@ -944,8 +917,7 @@ static void __make_rrule_ver1_default(calendar_record_h record, int freq, int in
 
        char *tzid = NULL;
        int d = 0;
-       switch (caltime.type)
-       {
+       switch (caltime.type) {
        case CALENDAR_TIME_UTIME:
                calendar_record_get_str_p(record, _calendar_event.start_tzid, &tzid);
                cal_time_get_local_datetime(tzid, caltime.time.utime, NULL, NULL, &d, NULL, NULL, NULL);
@@ -993,8 +965,7 @@ static void __make_rrule_ver1(cal_make_s *b, calendar_record_h record)
        RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
 
        int len = 0;
-       switch (freq)
-       {
+       switch (freq) {
        case CALENDAR_RECURRENCE_YEARLY:
                if (bymonth && *bymonth) {
                        DBG("bymonth");
@@ -1261,11 +1232,9 @@ static void __make_rrule(cal_make_s *b, calendar_record_h record)
        RET_IF(NULL == b);
        RET_IF(NULL == record);
 
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
-               switch (b->version)
-               {
+               switch (b->version) {
                case VCAL_VER_1:
                        __make_rrule_ver1(b, record);
                        break;
@@ -1284,7 +1253,7 @@ int _cal_vcalendar_make_attendee(cal_make_s *b, calendar_record_h attendee)
 {
        int ret;
 
-       RETV_IF(attendee == NULL, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == attendee, CALENDAR_ERROR_INVALID_PARAMETER);
 
        ret = _cal_vcalendar_make_set_str(b, "ATTENDEE");
        RETV_IF(CALENDAR_ERROR_NONE != ret, ret);
@@ -1292,8 +1261,7 @@ int _cal_vcalendar_make_attendee(cal_make_s *b, calendar_record_h attendee)
        int cutype = 0;
        ret = calendar_record_get_int(attendee, _calendar_attendee.cutype, &cutype);
        ret = _cal_vcalendar_make_set_str(b, ";CUTYPE=");
-       switch (cutype)
-       {
+       switch (cutype) {
        case CALENDAR_ATTENDEE_CUTYPE_INDIVIDUAL:
                ret = _cal_vcalendar_make_set_str(b, "INDIVIDUAL");
                break;
@@ -1346,8 +1314,7 @@ int _cal_vcalendar_make_attendee(cal_make_s *b, calendar_record_h attendee)
 
        char *delegatee_uri = NULL;
        ret = calendar_record_get_str_p(attendee, _calendar_attendee.delegatee_uri, &delegatee_uri);
-       if (delegatee_uri && *delegatee_uri)
-       {
+       if (delegatee_uri && *delegatee_uri) {
                ret = _cal_vcalendar_make_set_str(b, ";DELEGATED-TO=");
                ret = _cal_vcalendar_make_set_str(b, delegatee_uri);
                RETV_IF(CALENDAR_ERROR_NONE != ret, ret);
@@ -1355,8 +1322,7 @@ int _cal_vcalendar_make_attendee(cal_make_s *b, calendar_record_h attendee)
 
        char *delegator_uri = NULL;
        ret = calendar_record_get_str_p(attendee, _calendar_attendee.delegator_uri, &delegator_uri);
-       if (delegator_uri && *delegator_uri)
-       {
+       if (delegator_uri && *delegator_uri) {
                ret = _cal_vcalendar_make_set_str(b, ";DELEGATED-FROM=");
                ret = _cal_vcalendar_make_set_str(b, delegator_uri);
                RETV_IF(CALENDAR_ERROR_NONE != ret, ret);
@@ -1374,8 +1340,7 @@ int _cal_vcalendar_make_attendee(cal_make_s *b, calendar_record_h attendee)
 
        char *email = NULL;
        ret = calendar_record_get_str_p(attendee, _calendar_attendee.email, &email);
-       if (email && *email)
-       {
+       if (email && *email) {
                ret = _cal_vcalendar_make_set_str(b, ":mailto:");
                ret = _cal_vcalendar_make_set_str(b, email);
                RETV_IF(CALENDAR_ERROR_NONE != ret, ret);
@@ -1393,8 +1358,7 @@ static void __make_attendee(cal_make_s *b, calendar_record_h record)
        int ret = 0;
        unsigned int count = 0;
        int i;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_child_record_count(record, _calendar_event.calendar_attendee, &count);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() Fail(%d)", ret);
@@ -1425,8 +1389,7 @@ static void __make_alarm_ver1(cal_make_s *b, calendar_record_h record)
        int ret = 0;
        unsigned int count = 0;
        int i;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_child_record_count(record, _calendar_event.calendar_alarm, &count);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() Fail(%d)", ret);
@@ -1460,8 +1423,7 @@ static void __make_alarm_ver2(cal_make_s *b, calendar_record_h record)
        int ret = 0;
        unsigned int count = 0;
        int i;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_child_record_count(record, _calendar_event.calendar_alarm, &count);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() Fail(%d)", ret);
@@ -1492,11 +1454,9 @@ static void __make_alarm(cal_make_s *b, calendar_record_h record)
        RET_IF(NULL == b);
        RET_IF(NULL == record);
 
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
-               switch (b->version)
-               {
+               switch (b->version) {
                case VCAL_VER_1:
                        __make_alarm_ver1(b, record);
                        break;
@@ -1518,8 +1478,7 @@ static void __make_created_time(cal_make_s *b, calendar_record_h record)
 
        int ret = 0;
        long long int value = 0;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_lli(record, _calendar_event.created_time, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_lli() Fail(%d)", ret);
@@ -1535,8 +1494,7 @@ static void __make_created_time(cal_make_s *b, calendar_record_h record)
        char buf[128] = {0};
        snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
 
-       switch (b->version)
-       {
+       switch (b->version) {
        case VCAL_VER_1:
                _cal_vcalendar_make_printf(b, "DCREATED:", buf);
                break;
@@ -1553,8 +1511,7 @@ static void __make_summary(cal_make_s *b, calendar_record_h record)
 
        int ret = 0;
        char *value = NULL;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_str_p(record, _calendar_event.summary, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
@@ -1579,8 +1536,7 @@ static void __make_description(cal_make_s *b, calendar_record_h record)
 
        int ret = 0;
        char *value = NULL;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_str_p(record, _calendar_event.description, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
@@ -1605,8 +1561,7 @@ static void __make_location(cal_make_s *b, calendar_record_h record)
 
        int ret = 0;
        char *value = NULL;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_str_p(record, _calendar_event.location, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
@@ -1635,8 +1590,7 @@ static void __make_organizer(cal_make_s *b, calendar_record_h record)
        int ret = 0;
        char *name = NULL;
        char *email = NULL;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_str_p(record, _calendar_event.organizer_name, &name);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
@@ -1675,8 +1629,7 @@ static void __make_last_modified(cal_make_s *b, calendar_record_h record)
 
        int ret = 0;
        long long int value = 0;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_lli(record, _calendar_event.last_modified_time, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_lli() Fail(%d)", ret);
@@ -1704,13 +1657,11 @@ static void __make_status(cal_make_s *b, calendar_record_h record)
        int ret = 0;
        int value = 0;
        char *status = NULL;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_int(record, _calendar_event.event_status, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
-               switch (value)
-               {
+               switch (value) {
                case CALENDAR_EVENT_STATUS_NONE:
                        DBG("None status");
                        break;
@@ -1728,8 +1679,7 @@ static void __make_status(cal_make_s *b, calendar_record_h record)
        case CALENDAR_BOOK_TYPE_TODO:
                ret = calendar_record_get_int(record, _calendar_todo.todo_status, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
-               switch (value)
-               {
+               switch (value) {
                case CALENDAR_TODO_STATUS_NONE:
                        DBG("None status");
                        break;
@@ -1780,8 +1730,7 @@ static void __make_priority(cal_make_s *b, calendar_record_h record)
 
        int ret = 0;
        int value = 0;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_int(record, _calendar_event.priority, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
@@ -1792,11 +1741,9 @@ static void __make_priority(cal_make_s *b, calendar_record_h record)
                break;
        }
        int priority = 0;
-       switch (b->version)
-       {
+       switch (b->version) {
        case VCAL_VER_1:
-               switch (value)
-               {
+               switch (value) {
                case CALENDAR_EVENT_PRIORITY_HIGH:
                        priority = 2;
                        break;
@@ -1812,8 +1759,7 @@ static void __make_priority(cal_make_s *b, calendar_record_h record)
                }
                break;
        case VCAL_VER_2:
-               switch (value)
-               {
+               switch (value) {
                case CALENDAR_EVENT_PRIORITY_HIGH: // in version 2.0, one out of 1 ~ 4.
                        priority = 3;
                        break;
@@ -1858,8 +1804,7 @@ static void __make_categories(cal_make_s *b, calendar_record_h record)
 
        int ret = 0;
        char *value = NULL;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_str_p(record, _calendar_event.categories, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
@@ -1967,8 +1912,7 @@ static void __make_exdate(cal_make_s *b, calendar_record_h record)
 
        int ret = 0;
        char *value = NULL;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_str_p(record, _calendar_event.exdate, &value);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
@@ -2023,8 +1967,7 @@ static void __make_extended(cal_make_s *b, calendar_record_h record)
        int i;
        bool has_lunar = false;
        int calendar_system_type = 0;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_child_record_count(record, _calendar_event.extended, &count);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() Fail(%d)", ret);
@@ -2063,8 +2006,7 @@ static void __make_end(cal_make_s *b, calendar_record_h record)
        RET_IF(NULL == record);
 
        int ret = 0;
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = _cal_vcalendar_make_printf(b, "END:VEVENT", NULL);
                RETM_IF(CALENDAR_ERROR_NONE != ret, "_cal_vcalendar_make_printf() Fail(%d)", ret);
@@ -2179,8 +2121,7 @@ static void __devide_vcalendar_with_header(cal_make_s *b, calendar_record_h reco
        char *tzid = NULL;
        long long int created = 0;
 
-       switch (b->type)
-       {
+       switch (b->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_get_str_p(record, _calendar_event.start_tzid, &tzid);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Fail(%d)", ret);
@@ -2267,7 +2208,7 @@ static int __make_vcalendar(cal_make_s *b, calendar_list_h list)
                        DBG("Unable to understand uri[%s]", uri);
                }
 
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
        __make_footer(b);
 
        return CALENDAR_ERROR_NONE;
@@ -2298,7 +2239,7 @@ int cal_vcalendar_make_vcalendar(cal_make_s *b, calendar_list_h list)
                                break;
                        }
                }
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
        b->version = version;
        DBG("make as version(%d)", version);
 
index 1c55ef5..6a2cd7c 100644 (file)
@@ -386,13 +386,12 @@ static inline void __adjust_tzid(char *p)
 
 static void __unfolding(char *p)
 {
-       RET_IF(p == NULL);
+       RET_IF(NULL == p);
        RET_IF('\0' == *p);
 
        char *q = p;
        while ('\0' != *p) {
-               switch (*p)
-               {
+               switch (*p) {
                case '=':
                        if (VCAL_LF == *(p +1) && ' ' == *(p +2)) // ver1.0:out of spec, but allowed exceptional case
                                p += 3;
@@ -433,8 +432,7 @@ static void __decode_escaped_char(char *p)
        char *q = p;
        while ('\0' != *p) {
                if ('\\' == *p && *(p +1)) {
-                       switch (*(p +1))
-                       {
+                       switch (*(p +1)) {
                        case '\\':
                                *q = '\\';
                                p++;
@@ -660,8 +658,7 @@ static void __decode_duration(char *cursor, int len, int *tick, int *unit)
        int t = 0, u = 0;
        int i;
        for (i = 0; i < len; i++) {
-               switch (*(cursor + i))
-               {
+               switch (*(cursor + i)) {
                case '0':
                case '1':
                case '2':
@@ -794,8 +791,7 @@ static void __get_caltime(char *p, calendar_time_s *caltime, struct user_data *u
        RET_IF(NULL == caltime);
        RET_IF(NULL == ud);
 
-       switch (strlen(p))
-       {
+       switch (strlen(p)) {
        case VCAL_DATETIME_LENGTH_YYYYMMDD:
                caltime->type = CALENDAR_TIME_LOCALTIME;
                sscanf(p, VCAL_DATETIME_FORMAT_YYYYMMDD,
@@ -938,8 +934,7 @@ static void __work_component_property_uid(char *value, calendar_record_h record,
 
        int ret = 0;
        value = __decode_charset(value);
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_str(record, _calendar_event.uid, value);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_str() Fail(%d)", ret);
@@ -959,8 +954,7 @@ static void __work_component_property_recurrence_id(char *value, calendar_record
        RET_IF(NULL == ud);
 
        int ret = 0;
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_str(record, _calendar_event.recurrence_id, value +1);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_str() Fail(%d)", ret);
@@ -986,8 +980,7 @@ static void __work_component_property_dtstart(char *value, calendar_record_h rec
        char *tzid = NULL;
        tzid = ud->datetime_tzid ? ud->datetime_tzid : (ud->timezone_tzid ? ud->timezone_tzid : NULL);
 
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                if (tzid && *tzid) {
                        ret = cal_record_set_str(record, _calendar_event.start_tzid, tzid);
@@ -1015,8 +1008,7 @@ static void __work_component_property_created(char *value, calendar_record_h rec
        RET_IF(NULL == ud);
 
        int ret = 0;
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_lli(record, _calendar_event.created_time, cal_time_convert_lli(value));
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_lli() Fail(%d)", ret);
@@ -1038,8 +1030,7 @@ static void __work_component_property_description(char *value, calendar_record_h
 
        int ret = 0;
        value = __decode_charset(value);
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_str(record, _calendar_event.description, value);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_str() Fail(%d)", ret);
@@ -1059,8 +1050,7 @@ static void __work_component_property_last_modified(char *value, calendar_record
        RET_IF(NULL == ud);
 
        int ret = 0;
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_lli(record, _calendar_event.last_modified_time, cal_time_convert_lli(value));
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_lli() Fail(%d)", ret);
@@ -1081,8 +1071,7 @@ static void __work_component_property_location(char *value, calendar_record_h re
 
        int ret = 0;
        value = __decode_charset(value);
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_str(record, _calendar_event.location, value);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_str() Fail(%d)", ret);
@@ -1099,11 +1088,9 @@ static int __decode_priority(char *value, struct user_data *ud)
        int original_priority = atoi(value);
        int modified_priority = 0;
 
-       switch (ud->version)
-       {
+       switch (ud->version) {
        case VCAL_VER_1:
-               switch (original_priority)
-               {
+               switch (original_priority) {
                case 0:
                        modified_priority = CALENDAR_TODO_PRIORITY_LOW;
                        break;
@@ -1122,8 +1109,7 @@ static int __decode_priority(char *value, struct user_data *ud)
 
        case VCAL_VER_2:
        default:
-               switch (original_priority)
-               {
+               switch (original_priority) {
                case 1 ... 4:
                        modified_priority = CALENDAR_TODO_PRIORITY_HIGH;
                        break;
@@ -1154,8 +1140,7 @@ static void __work_component_property_priority(char *value, calendar_record_h re
 
        int ret = 0;
        int modified_priority = __decode_priority(value, ud);
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_int(record, _calendar_event.priority, modified_priority);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_int() Fail(%d)", ret);
@@ -1176,8 +1161,7 @@ static void __work_component_property_status(char *value, calendar_record_h reco
 
        int ret = 0;
        int status = 0;
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                if (CAL_STRING_EQUAL == strncmp(value, ":TENTATIVE", strlen(":TENTATIVE"))) {
                        status = CALENDAR_EVENT_STATUS_TENTATIVE;
@@ -1220,8 +1204,7 @@ static void __work_component_property_summary(char *value, calendar_record_h rec
 
        int ret = 0;
        value = __decode_charset(value);
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_str(record, _calendar_event.summary, value);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_str() Fail(%d)", ret);
@@ -1285,8 +1268,7 @@ static void __set_bystr(int freq_mode, calendar_record_h record, char *bystr)
        DBG("bystr[%s]", bystr);
        bystr[strlen(bystr) -1] = '\0'; // to remove ','
        int ret = 0;
-       switch (freq_mode)
-       {
+       switch (freq_mode) {
        case VCAL_RECURRENCE_YEARLY_BYMONTH:
                ret = cal_record_set_str(record, _calendar_event.bymonth, bystr);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_str() Fail(%d)", ret);
@@ -1399,16 +1381,14 @@ static void __work_component_property_rrule_ver_1(char *value, calendar_record_h
                        bool exit_loop = false;
                        int sign = 1;
                        int j = 0;
-                       switch (freq_mode)
-                       {
+                       switch (freq_mode) {
                        case VCAL_RECURRENCE_MONTHLY_BYDAY:
                        case VCAL_RECURRENCE_WEEKLY:
                                if (true == has_by) {
                                        week_index = 0;
                                }
                                while (*(t[i] +j)) {
-                                       switch (*(t[i] +j))
-                                       {
+                                       switch (*(t[i] +j)) {
                                        case '+':
                                                exit_loop = true;
                                                sign = 1;
@@ -1430,8 +1410,7 @@ static void __work_component_property_rrule_ver_1(char *value, calendar_record_h
                        default:
                                has_by = true;
                                while (*(t[i] +j)) {
-                                       switch (*(t[i] +j))
-                                       {
+                                       switch (*(t[i] +j)) {
                                        case '+':
                                                exit_loop = true;
                                                sign = 1;
@@ -1461,8 +1440,7 @@ static void __work_component_property_rrule_ver_1(char *value, calendar_record_h
                        if (VCAL_RECURRENCE_NONE != (freq_mode = __get_frequency(t[i]))) {
                                if (0 == frequency) {
                                        int interval = 0;
-                                       switch (freq_mode)
-                                       {
+                                       switch (freq_mode) {
                                        case VCAL_RECURRENCE_YEARLY_BYMONTH:
                                                frequency = CALENDAR_RECURRENCE_YEARLY;
                                                interval = ('\0' == *(t[i] +2)) ? 1 : atoi(t[i] +2);
@@ -1653,11 +1631,9 @@ static void __work_component_property_rrule(char *value, calendar_record_h recor
        RET_IF(NULL == record);
        RET_IF(NULL == ud);
 
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
-               switch (ud->version)
-               {
+               switch (ud->version) {
                case VCAL_VER_1:
                        __work_component_property_rrule_ver_1(value, record, ud);
                        break;
@@ -1687,8 +1663,7 @@ static void __work_component_property_dtend(char *value, calendar_record_h recor
        char *tzid = NULL;
        tzid = ud->datetime_tzid ? ud->datetime_tzid : (ud->timezone_tzid ? ud->timezone_tzid : NULL);
 
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                if (tzid && *tzid) {
                        ret = cal_record_set_str(record, _calendar_event.end_tzid, tzid);
@@ -1919,8 +1894,7 @@ static void __work_component_property_attendee(char *value, calendar_record_h re
        }
        g_strfreev(t);
 
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = calendar_record_add_child_record(record, _calendar_event.calendar_attendee, attendee);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() Fail(%d)", ret);
@@ -1941,8 +1915,7 @@ static void __work_component_property_categories(char *value, calendar_record_h
 
        int ret = 0;
        value = __decode_charset(value);
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_str(record, _calendar_event.categories, value);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_str() Fail(%d)", ret);
@@ -2015,8 +1988,7 @@ static void __work_component_property_dalarm(char *value, calendar_record_h reco
                return;
        }
 
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case VCALENDAR_TYPE_VEVENT:
                ret = calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() Fail(%d)", ret);
@@ -2094,8 +2066,7 @@ static void __work_component_property_malarm(char *value, calendar_record_h reco
                return;
        }
 
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case VCALENDAR_TYPE_VEVENT:
                ret = calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() Fail(%d)", ret);
@@ -2167,8 +2138,7 @@ static void __work_component_property_aalarm(char *value, calendar_record_h reco
                return;
        }
 
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case VCALENDAR_TYPE_VEVENT:
                ret = calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() Fail(%d)", ret);
@@ -2189,8 +2159,7 @@ static void __work_component_property_exdate(char *value, calendar_record_h reco
        RET_IF(NULL == ud);
 
        int ret = 0;
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case CALENDAR_BOOK_TYPE_EVENT:
                ret = cal_record_set_str(record, _calendar_event.exdate, value + 1);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_str() Fail(%d)", ret);
@@ -2214,8 +2183,7 @@ static void __work_component_property_x_allday(char *value, calendar_record_h re
                ud->is_allday = true;
 
                calendar_time_s caltime = {0};
-               switch (ud->type)
-               {
+               switch (ud->type) {
                case CALENDAR_BOOK_TYPE_EVENT:
                        ret = calendar_record_get_caltime(record, _calendar_event.start_time, &caltime);
                        WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() Fail");
@@ -2279,8 +2247,7 @@ static void __work_component_property_x_lunar(char *value, calendar_record_h rec
        int ret = 0;
        if (CAL_STRING_EQUAL == strncmp(value, ":SET", strlen(":SET"))) {
                DBG("x-lunar: set");
-               switch (ud->type)
-               {
+               switch (ud->type) {
                case CALENDAR_BOOK_TYPE_EVENT:
                        ret = cal_record_set_int(record, _calendar_event.calendar_system_type, CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR);
                        WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_int() Fail(%d)", ret);
@@ -2372,8 +2339,7 @@ static void __work_component_property_valarm_trigger(char *value, calendar_recor
                                                        break;
                                                }
                                        }
-                                       switch (related)
-                                       {
+                                       switch (related) {
                                        case VCAL_RELATED_START:
                                                ret = calendar_record_get_caltime(record, _calendar_event.start_time, &caltime);
                                                WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() Fail(%d)", ret);
@@ -2472,8 +2438,7 @@ static char* __work_component_property_begin(char *cursor, calendar_record_h rec
                cursor = __get_index(cursor, component_property_valarm, VCAL_COMPONENT_PROPERTY_VALARM_MAX, &index);
 
                char *value = NULL;
-               switch (index)
-               {
+               switch (index) {
                case VCAL_COMPONENT_PROPERTY_VALARM_ACTION:
                        cursor = __get_value(cursor, &value);
                        __work_component_property_valarm_action(value, alarm, ud);
@@ -2537,8 +2502,7 @@ static char* __work_component_property_begin(char *cursor, calendar_record_h rec
                if (true == exit_loop) break;
        }
 
-       switch (ud->type)
-       {
+       switch (ud->type) {
        case VCALENDAR_TYPE_VEVENT:
                ret = calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
                break;
@@ -2561,8 +2525,7 @@ static char* __work_component_vevent(char *cursor, calendar_record_h record, str
                cursor = __get_index(cursor, component_property, VCAL_COMPONENT_PROPERTY_MAX, &index);
 
                char *value = NULL;
-               switch (index)
-               {
+               switch (index) {
                case VCAL_COMPONENT_PROPERTY_DTSTAMP:
                        cursor = __get_value(cursor, &value);
                        __work_component_property_dtstamp(value, record, ud);
@@ -2735,8 +2698,7 @@ static char* __work_component_vjournal(char *cursor, calendar_record_h record, s
        while (cursor) {
                int index = 0;
                cursor = __get_index(cursor, component_property, VCAL_COMPONENT_PROPERTY_MAX, &index);
-               switch (index)
-               {
+               switch (index) {
                case VCAL_COMPONENT_PROPERTY_END:
                        DBG("exit record");
                        cursor = __crlf(cursor);
@@ -2762,8 +2724,7 @@ static char* __work_component_vfreebusy(char *cursor, calendar_record_h record,
        while (cursor) {
                int index = 0;
                cursor = __get_index(cursor, component_property, VCAL_COMPONENT_PROPERTY_MAX, &index);
-               switch (index)
-               {
+               switch (index) {
                case VCAL_COMPONENT_PROPERTY_END:
                        DBG("exit record");
                        cursor = __crlf(cursor);
@@ -2865,8 +2826,7 @@ static char* __work_component_vtimezone_standard(char *cursor, calendar_record_h
                cursor = __get_index(cursor, component_property_vtimezone, VCAL_COMPONENT_PROPERTY_VTIMEZONE_MAX, &index);
 
                char *value = NULL;
-               switch (index)
-               {
+               switch (index) {
                case VCAL_COMPONENT_PROPERTY_VTIMEZONE_DTSTART:
                        cursor = __get_value(cursor, &value);
                        __work_component_property_vtimezone_standard_dtstart(value +1, record, ud);
@@ -2979,8 +2939,7 @@ static char* __work_component_vtimezone_daylight(char *cursor, calendar_record_h
                cursor = __get_index(cursor, component_property_vtimezone, VCAL_COMPONENT_PROPERTY_VTIMEZONE_MAX, &index);
 
                char *value = NULL;
-               switch (index)
-               {
+               switch (index) {
                case VCAL_COMPONENT_PROPERTY_VTIMEZONE_DTSTART:
                        cursor = __get_value(cursor, &value);
                        __work_component_property_vtimezone_daylight_dtstart(value +1, record, ud);
@@ -3084,8 +3043,7 @@ static char* __work_property_begin(char *cursor, calendar_record_h *out_record,
        cursor = __get_index(cursor +1, vcal_component, VCAL_COMPONENT_MAX, &index);
        cursor = __crlf(cursor);
        calendar_record_h record = NULL;
-       switch (index)
-       {
+       switch (index) {
        case VCAL_COMPONENT_VEVENT:
                ret = calendar_record_create(_calendar_event._uri, &record);
                RETVM_IF(CALENDAR_ERROR_NONE != ret, NULL, "calendar_record_create() Fail(%d)", ret);
@@ -3143,8 +3101,7 @@ int cal_vcalendar_parse_vcalendar_object(char *stream, calendar_list_h list, vca
                int index = 0;
                char *value = NULL;
                cursor = __get_index(cursor, vcal_property, VCAL_PROPERTY_MAX, &index);
-               switch (index)
-               {
+               switch (index) {
                case VCAL_PROPERTY_VERSION:
                        cursor = __get_value(cursor, &value);
                        __get_version(value, &ud->version);
index 9b01c65..53ae300 100644 (file)
@@ -1044,17 +1044,14 @@ void cal_view_initialize(void)
        cal_mutex_unlock(CAL_MUTEX_PROPERTY_HASH);
 #endif
 
-       if (cal_uri_property_flag == false)
-       {
+       if (cal_uri_property_flag == false) {
                cal_mutex_lock(CAL_MUTEX_PROPERTY_HASH);
                bmutex = true;
        }
 
-       if (cal_uri_property_hash == NULL)
-       {
+       if (NULL == cal_uri_property_hash) {
                cal_uri_property_hash = g_hash_table_new(g_str_hash, g_str_equal);
-               if (cal_uri_property_hash)
-               {
+               if (cal_uri_property_hash) {
                        g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_CALENDAR, GINT_TO_POINTER(&(__tables[0])));
                        g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_EVENT, GINT_TO_POINTER(&(__tables[1])));
                        g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_TODO, GINT_TO_POINTER(&(__tables[2])));
@@ -1073,8 +1070,7 @@ void cal_view_initialize(void)
                }
        }
 
-       if (bmutex == true)
-       {
+       if (bmutex == true) {
                cal_uri_property_flag = true;
                cal_mutex_unlock(CAL_MUTEX_PROPERTY_HASH);
        }
@@ -1092,13 +1088,11 @@ cal_record_type_e cal_view_get_type(const char *view_uri)
                if (view_uri_info) {
                        type = view_uri_info->type;
                }
-               else
-               {
-                       ERR("g_hash_table_lookup() failed");
+               else {
+                       ERR("g_hash_table_lookup() Fail");
                }
        }
-       else
-       {
+       else {
                ERR("Unable to get cal_uri_property_hash[%s]", view_uri);
        }
 
@@ -1109,16 +1103,14 @@ void cal_view_finalize(void)
 {
 #ifdef CAL_IPC_CLIENT
        cal_mutex_lock(CAL_MUTEX_PROPERTY_HASH);
-       if (calendar_view_count <= 0)
-       {
+       if (calendar_view_count <= 0) {
                cal_mutex_unlock(CAL_MUTEX_PROPERTY_HASH);
                return ;
        }
        calendar_view_count--;
 
-       if (calendar_view_count == 0)
-       {
-               if (cal_uri_property_hash != NULL) {
+       if (calendar_view_count == 0) {
+               if (cal_uri_property_hash) {
                        g_hash_table_destroy(cal_uri_property_hash);
                        cal_uri_property_hash = NULL;
                }
index a0824a9..2238d93 100644 (file)
@@ -52,8 +52,7 @@ static int _cal_ipc_marshal_attribute_filter(const cal_attribute_filter_s* filte
 
 static cal_ipc_marshal_record_plugin_cb_s* _cal_ipc_marshal_get_plugin_cb(cal_record_type_e type)
 {
-       switch (type)
-       {
+       switch (type) {
        case CAL_RECORD_TYPE_CALENDAR:
                return (&cal_ipc_record_calendar_plugin_cb);
        case CAL_RECORD_TYPE_EVENT:
@@ -142,8 +141,8 @@ static int _cal_ipc_unmarshal_composite_filter(const pims_ipc_data_h ipc_data, c
                }
                if (filter_type == CAL_FILTER_COMPOSITE) {
                        cal_composite_filter_s* com_filter = NULL;
-                       com_filter = calloc(1,sizeof(cal_composite_filter_s));
-                       if (com_filter == NULL) {
+                       com_filter = (cal_composite_filter_s*)calloc(1,sizeof(cal_composite_filter_s));
+                       if (NULL == com_filter) {
                                ERR("calloc() Fail");
                                ret = CALENDAR_ERROR_OUT_OF_MEMORY;
                                goto ERROR_RETURN;
@@ -158,8 +157,8 @@ static int _cal_ipc_unmarshal_composite_filter(const pims_ipc_data_h ipc_data, c
                }
                else {
                        cal_attribute_filter_s* attr_filter = NULL;
-                       attr_filter = calloc(1,sizeof(cal_attribute_filter_s));
-                       if (attr_filter == NULL) {
+                       attr_filter = (cal_attribute_filter_s*)calloc(1,sizeof(cal_attribute_filter_s));
+                       if (NULL == attr_filter) {
                                ERR("calloc() Fail");
                                ret = CALENDAR_ERROR_OUT_OF_MEMORY;
                                goto ERROR_RETURN;
@@ -371,9 +370,8 @@ static int _cal_ipc_marshal_attribute_filter(const cal_attribute_filter_s* filte
                }
                break;
        case CAL_FILTER_LLI:
-               if (cal_ipc_marshal_lli((filter->value.lli),ipc_data) != CALENDAR_ERROR_NONE)
-               {
-                       ERR("cal_ipc_marshal fail");
+               if (cal_ipc_marshal_lli((filter->value.lli),ipc_data) != CALENDAR_ERROR_NONE) {
+                       ERR("cal_ipc_marshal Fail");
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
                break;
@@ -517,7 +515,7 @@ int cal_ipc_unmarshal_int(const pims_ipc_data_h data, int *pout)
        RETV_IF(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
 
        tmp = pims_ipc_data_get(data,&size);
-       if (tmp == NULL) {
+       if (NULL == tmp) {
                ERR("pims_ipc_data_get Fail");
                return CALENDAR_ERROR_NO_DATA;
        }
@@ -536,7 +534,7 @@ int cal_ipc_unmarshal_uint(const pims_ipc_data_h data, unsigned int *pout)
        RETV_IF(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
 
        tmp = pims_ipc_data_get(data,&size);
-       if (tmp == NULL) {
+       if (NULL == tmp) {
                ERR("pims_ipc_data_get Fail");
                return CALENDAR_ERROR_NO_DATA;
        }
@@ -554,7 +552,7 @@ int cal_ipc_unmarshal_lli(const pims_ipc_data_h data, long long int *pout)
        RETV_IF(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
        tmp = pims_ipc_data_get(data,&size);
-       if (tmp == NULL) {
+       if (NULL == tmp) {
                ERR("pims_ipc_data_get Fail");
                return CALENDAR_ERROR_NO_DATA;
        }
@@ -572,7 +570,7 @@ int cal_ipc_unmarshal_long(const pims_ipc_data_h data, long *pout)
        RETV_IF(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
        tmp = pims_ipc_data_get(data,&size);
-       if (tmp == NULL) {
+       if (NULL == tmp) {
                ERR("pims_ipc_data_get Fail");
                return CALENDAR_ERROR_NO_DATA;
        }
@@ -590,7 +588,7 @@ int cal_ipc_unmarshal_double(const pims_ipc_data_h data, double *pout)
        RETV_IF(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
        tmp = pims_ipc_data_get(data,&size);
-       if (tmp == NULL) {
+       if (NULL == tmp) {
                ERR("pims_ipc_data_get Fail");
                return CALENDAR_ERROR_NO_DATA;
        }
@@ -609,7 +607,7 @@ int cal_ipc_unmarshal_caltime(const pims_ipc_data_h data, calendar_time_s *pout)
        RETV_IF(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
        tmp = pims_ipc_data_get(data,&size);
-       if (tmp == NULL) {
+       if (NULL == tmp) {
                ERR("pims_ipc_data_get Fail");
                return CALENDAR_ERROR_NO_DATA;
        }
@@ -675,7 +673,7 @@ int cal_ipc_unmarshal_record_common(const pims_ipc_data_h ipc_data, cal_record_s
                }
                tmp_properties_flags = (unsigned char*)ret_pims;
                common->properties_flags = calloc(common->properties_max_count, sizeof(char));
-               if (common->properties_flags == NULL) {
+               if (NULL == common->properties_flags) {
                        ERR("calloc() Fail");
                        return CALENDAR_ERROR_OUT_OF_MEMORY;
                }
@@ -698,7 +696,7 @@ int cal_ipc_marshal_char(const char* bufchar, pims_ipc_data_h ipc_data)
 
        RETV_IF(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
 
-       if (bufchar != NULL) {
+       if (bufchar) {
                int length = strlen(bufchar);
                if (pims_ipc_data_put(ipc_data,(void*)&length,sizeof(int)) != 0) {
                        ret = CALENDAR_ERROR_OUT_OF_MEMORY;
@@ -897,7 +895,7 @@ int cal_ipc_unmarshal_query(const pims_ipc_data_h ipc_data, calendar_query_h *qu
 
        if (0 < que->projection_count) {
                que->projection = (unsigned int*)calloc(que->projection_count, sizeof(int));
-               if (que->projection == NULL) {
+               if (NULL == que->projection) {
                        ERR("calloc() Fail");
                        ret = CALENDAR_ERROR_OUT_OF_MEMORY;
                        goto ERROR_RETURN;
@@ -972,8 +970,7 @@ int cal_ipc_marshal_query(const calendar_query_h query, pims_ipc_data_h ipc_data
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
        }
-       else
-       {
+       else {
                if (cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE) {
                        ERR("cal_ipc_marshal fail");
                        return CALENDAR_ERROR_INVALID_PARAMETER;
index c8a7907..f32f216 100644 (file)
@@ -51,8 +51,8 @@ static int _cal_ipc_unmarshal_search(pims_ipc_data_h ipc_data, calendar_record_h
        for(i=0;i<count;i++) {
                cal_search_value_s* value_data = NULL;
                value_data = calloc(1, sizeof(cal_search_value_s));
-               if (value_data == NULL) {
-                       ERR("calloc fail");
+               if (NULL == value_data) {
+                       ERR("calloc() Fail");
                        return CALENDAR_ERROR_OUT_OF_MEMORY;
                }
 
@@ -85,7 +85,7 @@ static int _cal_ipc_marshal_search(const calendar_record_h record, pims_ipc_data
 
                while (cursor) {
                        value_data = (cal_search_value_s *)cursor->data;
-                       if (value_data == NULL) {
+                       if (NULL == value_data) {
                                cursor = g_slist_next(cursor);
                                continue;
                        }
index 989f947..0968a51 100644 (file)
@@ -239,7 +239,7 @@ bool cal_access_control_have_write_permission(int calendarbook_id)
                return false;
        }
 
-       while(1) {
+       while (1) {
                if (find->write_list[i] == -1)
                        break;
                if (calendarbook_id == find->write_list[i]) {
index 3d33fec..06fbbcb 100755 (executable)
@@ -53,8 +53,7 @@ extern cal_db_plugin_cb_s cal_db_extended_plugin_cb;
 
 static cal_db_plugin_cb_s* _cal_db_get_plugin(cal_record_type_e type)
 {
-       switch (type)
-       {
+       switch (type) {
        case CAL_RECORD_TYPE_CALENDAR:
                return (&cal_db_calendar_plugin_cb);
        case CAL_RECORD_TYPE_EVENT:
@@ -819,12 +818,10 @@ API int calendar_db_insert_records(calendar_list_h list, int** ids, int* count)
        int bulk = _count / div + 1;
 
        calendar_list_first(list);
-       for (i = 0; i < _count; i++)
-       {
+       for (i = 0; i < _count; i++) {
                calendar_record_h record = NULL;
                ret = calendar_list_get_current_record_p(list, &record);
-               if (record == NULL|| CALENDAR_ERROR_NONE != ret)
-               {
+               if (NULL == record|| ret != CALENDAR_ERROR_NONE) {
                        ERR("No record in the list");
                        cal_db_util_end_trans(false);
                        CAL_FREE(_ids);
@@ -833,16 +830,14 @@ API int calendar_db_insert_records(calendar_list_h list, int** ids, int* count)
 
                cal_record_s *temp = (cal_record_s *)record;
                cal_db_plugin_cb_s* plugin_cb = _cal_db_get_plugin(temp->type);
-               if (NULL == plugin_cb || NULL == plugin_cb->insert_record)
-               {
+               if (NULL == plugin_cb || NULL == plugin_cb->insert_record) {
                        DBG("Not plugin");
                        cal_db_util_end_trans(false);
                        CAL_FREE(_ids);
                        return CALENDAR_ERROR_NOT_PERMITTED;
                }
                ret = plugin_cb->insert_record(record, &_ids[i]);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        DBG("Failed to insert record");
                        cal_db_util_end_trans(false);
                        CAL_FREE(_ids);
@@ -851,14 +846,12 @@ API int calendar_db_insert_records(calendar_list_h list, int** ids, int* count)
                DBG("insert with id(%d)", _ids[i]);
                calendar_list_next(list);
 
-               if (bulk < i)
-               {
+               if (bulk < i) {
                        bulk += (_count / div + 1);
                        cal_db_util_end_trans(true);
                        sleep(1);
                        ret = cal_db_util_begin_trans();
-                       if (CALENDAR_ERROR_NONE != ret)
-                       {
+                       if (CALENDAR_ERROR_NONE != ret) {
                                calendar_list_destroy(list, true);
                                CAL_FREE(_ids);
                                ERR("Db failed");
@@ -868,14 +861,12 @@ API int calendar_db_insert_records(calendar_list_h list, int** ids, int* count)
        }
 
        if (ids)
-       {
                *ids = _ids;
-       }
        else
-       {
                CAL_FREE(_ids);
-       }
-       if (count) *count = _count;
+
+       if (count)
+               *count = _count;
        cal_db_util_end_trans(true);
 
        return ret;
@@ -904,12 +895,10 @@ API int calendar_db_update_records(calendar_list_h list)
        int bulk = count / div + 1;
 
        calendar_list_first(list);
-       for (i = 0; i < count; i++)
-       {
+       for (i = 0; i < count; i++) {
                calendar_record_h record = NULL;
                ret = calendar_list_get_current_record_p(list, &record);
-               if (record == NULL || CALENDAR_ERROR_NONE != ret)
-               {
+               if (NULL == record || ret != CALENDAR_ERROR_NONE) {
                        ERR("No record in the list");
                        cal_db_util_end_trans(false);
                        return ret;
@@ -917,31 +906,28 @@ API int calendar_db_update_records(calendar_list_h list)
 
                cal_record_s *temp = (cal_record_s *)record;
                cal_db_plugin_cb_s* plugin_cb = _cal_db_get_plugin(temp->type);
-               if (NULL == plugin_cb || NULL == plugin_cb->update_record)
-               {
+               if (NULL == plugin_cb || NULL == plugin_cb->update_record) {
                        ERR("Not plugin");
                        cal_db_util_end_trans(false);
                        ret = CALENDAR_ERROR_NOT_PERMITTED;
                        return ret;
                }
                ret = plugin_cb->update_record(record);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
-                       ERR("Failed to update record");
+               if (CALENDAR_ERROR_NONE != ret) {
+                       ERR("update_record() Fail(%d)", ret);
                        cal_db_util_end_trans(false);
                        return ret;
                }
                DBG("update record");
                calendar_list_next(list);
 
-               if (bulk < i)
-               {
+               if (bulk < i) {
                        bulk += (count / div + 1);
                        cal_db_util_end_trans(true);
                        sleep(1);
+
                        ret = cal_db_util_begin_trans();
-                       if (CALENDAR_ERROR_NONE != ret)
-                       {
+                       if (CALENDAR_ERROR_NONE != ret) {
                                calendar_list_destroy(list, true);
                                ERR("Db failed");
                                return CALENDAR_ERROR_DB_FAILED;
@@ -974,13 +960,10 @@ API int calendar_db_delete_records(const char* view_uri, int record_id_array[],
        ret = plugin_cb->delete_records(record_id_array,count);
 
        if (CALENDAR_ERROR_NONE == ret)
-       {
                ret = cal_db_util_end_trans(true);
-       }
        else
-       {
                cal_db_util_end_trans(false);
-       }
+
        return ret;
 }
 
@@ -1000,8 +983,7 @@ API int calendar_db_insert_vcalendars(const char* vcalendar_stream, int **record
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "parse fail");
 
        ret = calendar_list_get_count(list, &list_count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                calendar_list_destroy(list, true);
                ERR("get count fail");
                return ret;
@@ -1009,30 +991,26 @@ API int calendar_db_insert_vcalendars(const char* vcalendar_stream, int **record
 
        calendar_list_first(list);
        ids = calloc(1, sizeof(int)*list_count);
-       if (ids == NULL)
-       {
+       if (NULL == ids) {
                calendar_list_destroy(list, true);
-               ERR("calloc fail");
+               ERR("calloc() Fail");
                return CALENDAR_ERROR_OUT_OF_MEMORY;
        }
 
        ret = cal_db_util_begin_trans();
 
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                calendar_list_destroy(list, true);
                CAL_FREE(ids);
                ERR("Db failed");
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       for(i=0;i<list_count;i++)
-       {
+       for(i=0;i<list_count;i++) {
                calendar_record_h record = NULL;
 
                ret = calendar_list_get_current_record_p(list, &record);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        calendar_list_destroy(list, true);
                        CAL_FREE(ids);
                        ERR("list get fail");
@@ -1074,29 +1052,26 @@ API int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record
        RETVM_IF(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "count(%d)", count);
 
        ret = calendar_vcalendar_parse_to_calendar(vcalendar_stream, &list);
-       RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "parse fail");
+       RETVM_IF(ret != CALENDAR_ERROR_NONE, ret, "parse Fail");
 
        ret = calendar_list_get_count(list, &list_count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                calendar_list_destroy(list, true);
-               ERR("get count fail");
+               ERR("get count Fail");
                return ret;
        }
 
        // check count
-       if (count != list_count)
-       {
+       if (count != list_count) {
                calendar_list_destroy(list, true);
-               ERR("get count fail vcalendar_count=%d, input count=%d", list_count, count);
+               ERR("Mismatched count: vcalendar_count=%d, input count=%d", list_count, count);
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        calendar_list_first(list);
 
        ret = cal_db_util_begin_trans();
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                calendar_list_destroy(list, true);
                ERR("Db failed");
                return CALENDAR_ERROR_DB_FAILED;
@@ -1106,8 +1081,7 @@ API int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record
        int div = (int)(count / BULK_DEFAULT_COUNT) + 1;
        int bulk = count / div + 1;
 
-       for(i = 0; i < list_count; i++)
-       {
+       for(i = 0; i < list_count; i++) {
                calendar_record_h record = NULL;
                char *view_uri = NULL;
 
@@ -1128,16 +1102,11 @@ API int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record
                        return ret;
                }
 
-               if (CAL_STRING_EQUAL == strcmp(view_uri, _calendar_event._uri))
-               {
+               if (CAL_STRING_EQUAL == strcmp(view_uri, _calendar_event._uri)) {
                        ret = cal_record_set_int(record, _calendar_event.id, record_id_array[i]);
-               }
-               else if (CAL_STRING_EQUAL == strcmp(view_uri, _calendar_todo._uri))
-               {
+               } else if (CAL_STRING_EQUAL == strcmp(view_uri, _calendar_todo._uri)) {
                        ret = cal_record_set_int(record, _calendar_todo.id, record_id_array[i]);
-               }
-               else
-               {
+               } else {
                        DBG("this uri[%s] is not replacable.", view_uri);
                        calendar_list_next(list);
                        continue;
@@ -1160,14 +1129,12 @@ API int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record
                }
                calendar_list_next(list);
 
-               if (bulk < i)
-               {
+               if (bulk < i) {
                        bulk += (count / div + 1);
                        cal_db_util_end_trans(true);
                        sleep(1);
                        ret = cal_db_util_begin_trans();
-                       if (CALENDAR_ERROR_NONE != ret)
-                       {
+                       if (CALENDAR_ERROR_NONE != ret) {
                                calendar_list_destroy(list, true);
                                ERR("Db failed");
                                return CALENDAR_ERROR_DB_FAILED;
@@ -1316,8 +1283,7 @@ API int calendar_db_get_changes_exception_by_version(const char* view_uri, int o
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                int id = 0, calendar_id = 0,type = 0;
                int ver = 0;
@@ -1325,7 +1291,7 @@ API int calendar_db_get_changes_exception_by_version(const char* view_uri, int o
                // stmt -> record
                ret = calendar_record_create(_calendar_updated_info._uri,&record);
                if (CALENDAR_ERROR_NONE != ret) {
-                       ERR("calendar_record_create() failed");
+                       ERR("calendar_record_create() Fail");
                        calendar_list_destroy(*record_list, true);
                        *record_list = NULL;
                        sqlite3_finalize(stmt);
@@ -1336,16 +1302,11 @@ API int calendar_db_get_changes_exception_by_version(const char* view_uri, int o
                ver = sqlite3_column_int(stmt, 1);
                created_ver = sqlite3_column_int(stmt, 2);
                is_deleted = sqlite3_column_int(stmt, 3);
-               if (is_deleted == 1)
-               {
+               if (is_deleted == 1) {
                        type = CALENDAR_RECORD_MODIFIED_STATUS_DELETED;
-               }
-               else if (created_ver != ver)
-               {
+               } else if (created_ver != ver) {
                        type = CALENDAR_RECORD_MODIFIED_STATUS_UPDATED;
-               }
-               else
-               {
+               } else {
                        type = CALENDAR_RECORD_MODIFIED_STATUS_INSERTED;
                }
 
index 2145171..9ff7e5a 100644 (file)
@@ -224,8 +224,7 @@ int cal_db_alarm_get_records(int parent, cal_list_s *list)
                        if (temp) {
                                int y = 0, m = 0, d = 0;
                                int h = 0, n = 0, s = 0;
-                               switch (strlen((const char*)temp))
-                               {
+                               switch (strlen((const char*)temp)) {
                                case 8:
                                        sscanf((const char *)temp, "%04d%02d%02d", &y, &m, &d);
                                        alarm->alarm.time.date.year = y;
index 1cdf3b4..14b1cfc 100644 (file)
@@ -48,8 +48,7 @@ int calendar_db_delete_account(int account_id)
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                int id = 0;
                id = sqlite3_column_int(stmt, 0);
                calendar_list = g_list_append(calendar_list, GINT_TO_POINTER(id));
@@ -60,22 +59,19 @@ int calendar_db_delete_account(int account_id)
                DBG("calendar cnt=%d",g_list_length(calendar_list));
 
        ret = cal_db_util_begin_trans();
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                g_list_free(calendar_list);
                ERR("db failed");
                return CALENDAR_ERROR_DB_FAILED;
        }
 
        GList* cursor = calendar_list;
-       while(cursor)
-       {
+       while (cursor) {
                int id = GPOINTER_TO_INT(cursor->data);
 
                ret = calendar_db_delete_record(_calendar_book._uri, id);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
-                       ERR("calendar_id(%d) delete fail~ ",id);
+               if (CALENDAR_ERROR_NONE != ret) {
+                       ERR("calendar_id(%d) delete Fail",id);
                }
                cursor = g_list_next(cursor);
        }
index fa4c192..b29869b 100644 (file)
@@ -253,8 +253,7 @@ static void cal_db_event_apply_recurrence_id_child(int child_id, cal_event_s *ev
        if (true == is_prior) {
                cal_record_set_caltime(record, _calendar_event.start_time, event->start);
                cal_record_set_caltime(record, _calendar_event.end_time, event->end);
-               switch (event->start.type)
-               {
+               switch (event->start.type) {
                case CALENDAR_TIME_UTIME:
                        DBG("dtstart(%lld) dtend(%lld)", event->start.time.utime, event->end.time.utime);
                        break;
@@ -302,8 +301,7 @@ static void __get_next_instance_caltime(int parent_id, calendar_time_s *caltime,
        char query[CAL_DB_SQL_MAX_LEN] = {0};
        sqlite3_stmt *stmt = NULL;
 
-       switch (caltime->type)
-       {
+       switch (caltime->type) {
        case CALENDAR_TIME_UTIME:
                snprintf(query, sizeof(query), "SELECT dtstart_utime, dtend_utime FROM %s WHERE event_id=%d AND dtstart_utime>%lld "
                                "ORDER BY dtstart_utime ASC LIMIT 1",
@@ -355,8 +353,7 @@ static void __get_last_instance_caltime(int parent_id, int type, calendar_time_s
        char query[CAL_DB_SQL_MAX_LEN] = {0};
        sqlite3_stmt *stmt = NULL;
 
-       switch (type)
-       {
+       switch (type) {
        case CALENDAR_TIME_UTIME:
                snprintf(query, sizeof(query), "SELECT dtstart_utime FROM %s WHERE event_id=%d "
                                "ORDER BY dtstart_utime DESC LIMIT 1",
@@ -395,8 +392,7 @@ static void __get_last_instance_caltime(int parent_id, int type, calendar_time_s
 static void __del_recurence_id_instance(calendar_time_s *rectime, int parent_id)
 {
        char query[CAL_DB_SQL_MAX_LEN] = {0};
-       switch (rectime->type)
-       {
+       switch (rectime->type) {
        case CALENDAR_TIME_UTIME:
                snprintf(query, sizeof(query), "DELETE FROM %s WHERE dtstart_utime=%lld AND event_id=%d",
                                CAL_TABLE_NORMAL_INSTANCE, rectime->time.utime, parent_id);
@@ -416,8 +412,7 @@ static void __del_recurence_id_instance(calendar_time_s *rectime, int parent_id)
        // debug
        int y = 0, m = 0, d = 0;
        int h = 0, n = 0, s = 0;
-       switch (rectime->type)
-       {
+       switch (rectime->type) {
        case CALENDAR_TIME_UTIME:
                cal_time_get_datetime(rectime->time.utime, &y, &m, &d, &h, &n, &s);
                DBG("[DELETED] %04d-%02d-%02dT%02d:%02d:%02d (utime)", y, m, d, h, n, s);
@@ -481,8 +476,7 @@ void cal_db_event_apply_recurrence_id(int parent_id, cal_event_s *event, char *r
        char dtstart_datetime[32] = {0};
        long long int dtstart_utime = 0;
        calendar_time_s rectime = {0};
-       switch (len_datetime)
-       {
+       switch (len_datetime) {
        case 8:
                sscanf(datetime, "%04d%02d%02d", &y, &m, &d);
                snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME, y, m, d, 0, 0, 0);
@@ -524,12 +518,10 @@ void cal_db_event_apply_recurrence_id(int parent_id, cal_event_s *event, char *r
        calendar_time_s dtstart = {0};
        calendar_time_s dtend = {0};
        calendar_record_h record = (calendar_record_h)event;
-       switch (range)
-       {
+       switch (range) {
        case CAL_RECURRENCE_ID_RANGE_THISANDFUTURE:
                DBG("update child");
-               switch (event->range_type)
-               {
+               switch (event->range_type) {
                case CALENDAR_RANGE_UNTIL:
                case CALENDAR_RANGE_NONE:
                        until = event->start;
@@ -558,8 +550,7 @@ void cal_db_event_apply_recurrence_id(int parent_id, cal_event_s *event, char *r
                __get_next_instance_caltime(parent_id, &until, &dtstart, &dtend);
                cal_record_set_caltime(record, _calendar_event.start_time, dtstart);
                cal_record_set_caltime(record, _calendar_event.end_time, dtend);
-               switch (event->range_type)
-               {
+               switch (event->range_type) {
                case CALENDAR_RANGE_UNTIL:
                case CALENDAR_RANGE_NONE:
                        break;
index a0a0be7..151a3a9 100644 (file)
@@ -153,8 +153,7 @@ int cal_db_extended_insert_record(calendar_record_h record, int record_id, calen
                *id = index;
        }
 
-       if (record_type == CALENDAR_RECORD_TYPE_EVENT || record_type == CALENDAR_RECORD_TYPE_TODO)
-       {
+       if (record_type == CALENDAR_RECORD_TYPE_EVENT || record_type == CALENDAR_RECORD_TYPE_TODO) {
                snprintf(query, sizeof(query), "UPDATE %s SET "
                                "has_extended = 1 "
                                "WHERE id = %d;",
index 226d95c..770883d 100644 (file)
@@ -70,8 +70,7 @@ static void __print_ucal(int calendar_system_type, UCalendar *ucal, const char *
 
        UCalendar *s_ucal = NULL;
 
-       switch (calendar_system_type)
-       {
+       switch (calendar_system_type) {
        case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
                s_ucal = cal_time_get_ucal(tzid, wkst);
                ucal_setMillis(s_ucal, ucal_getMillis(ucal, &ec), &ec);
@@ -101,8 +100,7 @@ static void __get_allday_date(cal_event_s *event, UCalendar *ucal, int *y, int *
 
        UCalendar *s_ucal = NULL;
 
-       switch (event->system_type)
-       {
+       switch (event->system_type) {
        case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
                s_ucal = cal_time_get_ucal(event->start_tzid, event->wkst);
                if (NULL == s_ucal) {
@@ -146,8 +144,7 @@ static int _cal_db_instance_parse_byint(char *byint, int *by, int *len)
        int length = g_strv_length(t);
        int i;
        int index = 0;
-       for (i = 0 ; i < length; i++)
-       {
+       for (i = 0 ; i < length; i++) {
                if (NULL == t[i] || 0 == strlen(t[i])) continue;
                by[index] = atoi(t[i]);
                index++;
@@ -167,16 +164,13 @@ static void __set_time_to_ucal(int calendar_system_type, UCalendar *ucal, calend
        int y = 0, m = 0, d = 0;
        int h = 0, n = 0, s = 0;
        struct tm tm = {0};
-       time_t tt = 0;
-       switch (t->type)
-       {
+       switch (t->type) {
        case CALENDAR_TIME_UTIME:
                ucal_setMillis(ucal, sec2ms(t->time.utime), &ec);
                break;
 
        case CALENDAR_TIME_LOCALTIME:
-               switch (calendar_system_type)
-               {
+               switch (calendar_system_type) {
                case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
                        tm.tm_year = t->time.date.year - 1900;
                        tm.tm_mon = t->time.date.month -1;
@@ -214,7 +208,7 @@ static int __get_exdate_list(UCalendar *ucal, cal_event_s *event, GList **l, int
        RETV_IF(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
 
-       if (event->exdate == NULL || '\0' == *(event->exdate)) {
+       if (NULL == event->exdate || '\0' == *(event->exdate)) {
                return CALENDAR_ERROR_NONE;
        }
 
@@ -238,8 +232,7 @@ static int __get_exdate_list(UCalendar *ucal, cal_event_s *event, GList **l, int
                long long int lli = 0;
                UCalendar *ucal2 = NULL;
                UErrorCode ec = U_ZERO_ERROR;
-               switch (strlen(p))
-               {
+               switch (strlen(p)) {
                case 8:
                        DBG("ALLDAY instance");
                        sscanf(p, "%04d%02d%02d", &y, &m, &d);
@@ -284,8 +277,7 @@ static int _cal_db_instance_update_exdate_mod(int original_event_id, char *recur
        char *p = NULL;
        char query[CAL_DB_SQL_MAX_LEN] = {0};
 
-       if (original_event_id < 1 || recurrence_id == NULL)
-       {
+       if (original_event_id < 1 || NULL == recurrence_id) {
                DBG("Nothing to update exdate mod");
                return CALENDAR_ERROR_NONE;
        }
@@ -307,8 +299,7 @@ static int _cal_db_instance_update_exdate_mod(int original_event_id, char *recur
                int y = 0, m = 0, d = 0;
                int h = 0, n = 0, s = 0;
                char buf[32] = {0};
-               switch (strlen(p))
-               {
+               switch (strlen(p)) {
                case 8:
                        DBG("ALLDAY instance");
                        sscanf(p, "%04d%02d%02d", &y, &m, &d);
@@ -502,7 +493,7 @@ static int _cal_db_instance_get_duration(UCalendar *ucal, calendar_time_s *st, c
 
                _duration = ucal_getFieldDifference(ucal, ud, UCAL_SECOND, &ec);
                if (U_FAILURE(ec)) {
-                       ERR("ucal_getFieldDifference failed (%s)", u_errorName(ec));
+                       ERR("ucal_getFieldDifference Fail (%s)", u_errorName(ec));
                        return ec;
                }
                break;
@@ -692,8 +683,7 @@ static bool __check_out_of_range(long long int current_utime, cal_event_s *event
        RETV_IF(NULL == event, true);
 
        // check range
-       switch (event->range_type)
-       {
+       switch (event->range_type) {
        case CALENDAR_RANGE_UNTIL:
        case CALENDAR_RANGE_NONE:
                if (until_utime < current_utime) {
@@ -805,16 +795,14 @@ static int _cal_db_instance_publish_yearly_yday(UCalendar *ucal, cal_event_s *ev
        bool is_exit = false;
        long long int last_utime = 0;
        long long int current_utime = 0;
-       while (false == is_exit)
-       {
+       while (false == is_exit) {
                calendar_time_s *st = &event->start;
                __set_time_to_ucal(event->system_type, ucal, st);
                long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
                ucal_add(ucal, UCAL_YEAR, event->interval * loop, &ec);
 
                int i;
-               for (i = 0; i < byyearday_len; i++)
-               {
+               for (i = 0; i < byyearday_len; i++) {
                        ucal_set(ucal, UCAL_DAY_OF_YEAR, byyearday[i]);
                        if (true == __check_bysetpos_to_skip(i, bysetpos, bysetpos_len, byyearday_len)) {
                                continue;
@@ -892,8 +880,7 @@ static int _cal_db_instance_publish_yearly_weekno(UCalendar *ucal, cal_event_s *
        bool is_exit = false;
        long long int last_utime = 0;
        long long int current_utime = 0;
-       while (false == is_exit)
-       {
+       while (false == is_exit) {
                calendar_time_s *st = &event->start;
                __set_time_to_ucal(event->system_type, ucal, st);
                long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
@@ -1020,8 +1007,7 @@ static int _cal_db_instance_publish_yearly_wday(UCalendar *ucal, cal_event_s *ev
        bool is_exit = false;
        long long int last_utime = 0;
        long long int current_utime = 0;
-       while (false == is_exit)
-       {
+       while (false == is_exit) {
                calendar_time_s *st = &event->start;
                __set_time_to_ucal(event->system_type, ucal, st);
                long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
@@ -1226,8 +1212,7 @@ static int _cal_db_instance_publish_yearly_mday(UCalendar *ucal, cal_event_s *ev
        bool is_exit = false;
        long long int last_utime = 0;
        long long int current_utime = 0;
-       while (false == is_exit)
-       {
+       while (false == is_exit) {
                calendar_time_s *st = &event->start;
                __set_time_to_ucal(event->system_type, ucal, st);
                long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
@@ -1358,8 +1343,7 @@ static int _cal_db_instance_publish_monthly_wday(UCalendar *ucal, cal_event_s *e
        bool is_exit = false;
        long long int last_utime = 0;
        long long int current_utime = 0;
-       while (false == is_exit)
-       {
+       while (false == is_exit) {
                calendar_time_s *st = &event->start;
                __set_time_to_ucal(event->system_type, ucal, st);
                long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
@@ -1551,8 +1535,7 @@ static int _cal_db_instance_publish_monthly_mday(UCalendar *ucal, cal_event_s *e
        bool is_exit = false;
        long long int last_utime = 0;
        long long int current_utime = 0;
-       while (false == is_exit)
-       {
+       while (false == is_exit) {
                calendar_time_s *st = &event->start;
                __set_time_to_ucal(event->system_type, ucal, st);
                long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
@@ -1657,8 +1640,7 @@ static int _cal_db_instance_publish_weekly_wday(UCalendar *ucal, cal_event_s *ev
        bool is_exit = false;
        long long int last_utime = 0;
        long long int current_utime = 0;
-       while (false == is_exit)
-       {
+       while (false == is_exit) {
                calendar_time_s *st = &event->start;
                __set_time_to_ucal(event->system_type, ucal, st);
                long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
@@ -1738,8 +1720,7 @@ static int _cal_db_instance_publish_daily_mday(UCalendar *ucal, cal_event_s *eve
        long long int last_utime = 0;
        long long int current_utime = 0;
        int log_value = 0;
-       while (false == is_exit)
-       {
+       while (false == is_exit) {
                if (loop) ucal_add(ucal, UCAL_DAY_OF_YEAR, event->interval, &ec);
 
                if (true == __check_daily_bymonth_to_skip(ucal, bymonth, bymonth_len, &log_value)) {
@@ -1799,22 +1780,19 @@ static int _cal_db_instance_publish_record_details(UCalendar *ucal, cal_event_s
        _cal_db_instance_get_duration(ucal, &event->start, &event->end, &duration);
        WARN_IF(duration < 0, "Invalid duration (%lld)", duration);
 
-       if (0 < event->original_event_id)
-       {
+       if (0 < event->original_event_id) {
                DBG("this is exception event so publish only one instance");
                exception_freq = event->freq;
                event->freq = CALENDAR_RECURRENCE_NONE;
        }
 
        DBG("event interval(%d)", event->interval);
-       if (event->interval < 1)
-       {
+       if (event->interval < 1) {
                DBG("Invalid interval, so set 1");
                event->interval = 1;
        }
 
-       switch (event->freq)
-       {
+       switch (event->freq) {
        case CALENDAR_RECURRENCE_YEARLY:
                _cal_db_instance_publish_record_yearly(ucal, event, duration);
                break;
@@ -1837,8 +1815,7 @@ static int _cal_db_instance_publish_record_details(UCalendar *ucal, cal_event_s
                break;
        }
 
-       if (0 < event->original_event_id)
-       {
+       if (0 < event->original_event_id) {
                DBG("return freq for exception event");
                event->freq = exception_freq;
        }
@@ -1853,17 +1830,15 @@ int cal_db_instance_update_exdate_del(int id, char *exdate)
        char **t = NULL;
        char *p = NULL;
 
-       if (exdate == NULL || strlen(exdate) == 0)
-       {
+       if (NULL == exdate || '\0' == *exdate) {
                DBG("Nothing to update exdate del");
                return CALENDAR_ERROR_NONE;
        }
 
        DBG("exdate[%s]", exdate);
        t = g_strsplit_set(exdate, " ,", -1);
-       if (!t)
-       {
-               ERR("g_strsplit_set failed");
+       if (NULL == t) {
+               ERR("g_strsplit_set() Fail");
                return CALENDAR_ERROR_OUT_OF_MEMORY;
        }
 
@@ -1877,8 +1852,7 @@ int cal_db_instance_update_exdate_del(int id, char *exdate)
                p = t[i];
                DBG("exdate[%s]", p);
                int len = strlen(p);
-               switch (len)
-               {
+               switch (len) {
                case 8: // 20141212
                        DBG("ALLDAY instance");
                        sscanf(p, "%04d%02d%02d", &y, &m, &d);
index 16a2741..76b2836 100644 (file)
@@ -85,20 +85,17 @@ static void _cal_db_alarm_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
        temp = sqlite3_column_text(stmt, index++);
        alarm->alarm_attach = SAFE_STRDUP(temp);
 
-       if (alarm->alarm.type == CALENDAR_TIME_UTIME)
-       {
+       if (alarm->alarm.type == CALENDAR_TIME_UTIME) {
                alarm->alarm.time.utime = sqlite3_column_int64(stmt,index++);
                index++; // datetime
        }
-       else
-       {
+       else {
                index++; // utime
                temp = sqlite3_column_text(stmt, index++);
                if (temp) {
                        int y = 0, m = 0, d = 0;
                        int h = 0, n = 0, s = 0;
-                       switch (strlen((const char *)temp))
-                       {
+                       switch (strlen((const char *)temp)) {
                        case 8:
                                sscanf((const char *)temp, "%04d%02d%02d", &y, &m, &d);
                                alarm->alarm.time.date.year = y;
@@ -224,8 +221,7 @@ static void _cal_db_alarm_get_property_stmt(sqlite3_stmt *stmt,
                        if (temp) {
                                int y = 0, m = 0, d = 0;
                                int h = 0, n = 0, s = 0;
-                               switch (strlen((const char *)temp))
-                               {
+                               switch (strlen((const char *)temp)) {
                                case 8:
                                        sscanf((const char *)temp, "%04d%02d%02d", &y, &m, &d);
                                        alarm->alarm.time.date.year = y;
@@ -281,7 +277,7 @@ static int _cal_db_alarm_get_records_with_query(calendar_query_h query, int offs
        que = (cal_query_s *)query;
 
        if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_ALARM)) {
-               table_name = CAL_SAFE_STRDUP(CAL_TABLE_ALARM);
+               table_name = SAFE_STRDUP(CAL_TABLE_ALARM);
        }
        else {
                ERR("uri(%s) not support get records with query",que->view_uri);
@@ -460,7 +456,7 @@ static int _cal_db_alarm_get_count_with_query(calendar_query_h query, int *out_c
        que = (cal_query_s *)query;
 
        if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_ALARM))     {
-               table_name = CAL_SAFE_STRDUP(CAL_TABLE_ALARM);
+               table_name = SAFE_STRDUP(CAL_TABLE_ALARM);
        }
        else {
                ERR("uri(%s) not support get records with query",que->view_uri);
index a547ac3..ae45cb5 100644 (file)
@@ -246,7 +246,7 @@ static int _cal_db_attendee_get_records_with_query(calendar_query_h query, int o
        que = (cal_query_s *)query;
 
        if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_ATTENDEE)) {
-               table_name = CAL_SAFE_STRDUP(CAL_TABLE_ATTENDEE);
+               table_name = SAFE_STRDUP(CAL_TABLE_ATTENDEE);
        }
        else {
                ERR("uri(%s) not support get records with query",que->view_uri);
@@ -425,7 +425,7 @@ static int _cal_db_attendee_get_count_with_query(calendar_query_h query, int *ou
        que = (cal_query_s *)query;
 
        if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_ATTENDEE)) {
-               table_name = CAL_SAFE_STRDUP(CAL_TABLE_ATTENDEE);
+               table_name = SAFE_STRDUP(CAL_TABLE_ATTENDEE);
        }
        else {
                ERR("uri(%s) not support get records with query",que->view_uri);
@@ -437,7 +437,7 @@ static int _cal_db_attendee_get_count_with_query(calendar_query_h query, int *ou
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
                if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
-                       ERR("filter create fail");
+                       ERR("filter create Fail");
                        return ret;
                }
        }
index f28969a..b16d9e5 100644 (file)
@@ -194,9 +194,7 @@ static int _cal_db_calendar_insert_record(calendar_record_h record, int* id)
 
        //cal_record_set_int(record, _calendar_book.id,index);
        if (id)
-       {
                *id = index;
-       }
 
        cal_db_util_notify(CAL_NOTI_TYPE_CALENDAR);
 
@@ -350,36 +348,28 @@ static int _cal_db_calendar_delete_record(int id)
        int count = 0;
        int count2 = 0;
        // get instance count
-       snprintf(query, sizeof(query), "select count(*) from %s",
-                       CAL_TABLE_NORMAL_INSTANCE);
+       snprintf(query, sizeof(query), "select count(*) from %s", CAL_TABLE_NORMAL_INSTANCE);
        ret = cal_db_util_query_get_first_int_result(query, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                return ret;
        }
 
-       snprintf(query, sizeof(query), "select count(*) from %s",
-                       CAL_TABLE_ALLDAY_INSTANCE);
+       snprintf(query, sizeof(query), "select count(*) from %s", CAL_TABLE_ALLDAY_INSTANCE);
        ret = cal_db_util_query_get_first_int_result(query,NULL, &count2);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                return ret;
        }
 
        count += count2;
 
-       if (1000 < count)
-       {
-               snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d",
-                               CAL_TABLE_CALENDAR, id);
+       if (1000 < count) {
+               snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d", CAL_TABLE_CALENDAR, id);
                dbret = cal_db_util_query_exec(query);
-               if (CAL_DB_OK != dbret)
-               {
+               if (CAL_DB_OK != dbret) {
                        ERR("cal_db_util_query_exec() Fail(%d)", dbret);
-                       switch (dbret)
-                       {
+                       switch (dbret) {
                        case CAL_DB_ERROR_NO_SPACE:
                                return CALENDAR_ERROR_FILE_NO_SPACE;
                        default:
@@ -388,14 +378,11 @@ static int _cal_db_calendar_delete_record(int id)
                }
                cal_server_calendar_delete_start();
        }
-       else
-       {
+       else {
 #endif
-               snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d",
-                               CAL_TABLE_CALENDAR, id);
+               snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d", CAL_TABLE_CALENDAR, id);
                dbret = cal_db_util_query_exec(query);
-               if (CAL_DB_OK != dbret)
-               {
+               if (CAL_DB_OK != dbret) {
                        ERR("cal_db_util_query_exec() Fail(%d)", dbret);
                        switch (dbret)
                        {
@@ -406,8 +393,7 @@ static int _cal_db_calendar_delete_record(int id)
                        }
                }
 
-               snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d",
-                               CAL_TABLE_SCHEDULE, id);
+               snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d", CAL_TABLE_SCHEDULE, id);
                dbret = cal_db_util_query_exec(query);
                if (CAL_DB_OK != dbret) {
                        ERR("cal_db_util_query_exec() Fail(%d)", dbret);
@@ -459,7 +445,7 @@ static int _cal_db_calendar_replace_record(calendar_record_h record, int id)
        }
 
        calendar->index = id;
-       if (calendar->common.properties_flags != NULL) {
+       if (calendar->common.properties_flags) {
                return _cal_db_calendar_update_projection(record);
        }
 
@@ -762,7 +748,7 @@ static int _cal_db_calendar_insert_records(const calendar_list_h list, int** ids
 
        id = calloc(1, sizeof(int)*count);
 
-       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
 
        ret = calendar_list_first(list);
        if (CALENDAR_ERROR_NONE != ret) {
@@ -780,7 +766,7 @@ static int _cal_db_calendar_insert_records(const calendar_list_h list, int** ids
                        }
                }
                i++;
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
        if (ids) {
                *ids = id;
@@ -810,7 +796,7 @@ static int _cal_db_calendar_update_records(const calendar_list_h list)
                                return CALENDAR_ERROR_DB_FAILED;
                        }
                }
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
        return CALENDAR_ERROR_NONE;
 }
@@ -897,7 +883,7 @@ static int _cal_db_calendar_get_count_with_query(calendar_query_h query, int *ou
        que = (cal_query_s *)query;
 
        if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_CALENDAR)) {
-               table_name = CAL_SAFE_STRDUP(CAL_TABLE_CALENDAR);
+               table_name = SAFE_STRDUP(CAL_TABLE_CALENDAR);
        }
        else {
                ERR("uri(%s) not support get records with query",que->view_uri);
index 7bab0b8..28fed75 100644 (file)
@@ -143,8 +143,7 @@ static int _cal_db_event_get_record(int id, calendar_record_h* out_record)
        calendar_book_sync_event_type_e sync_event_type = CALENDAR_BOOK_SYNC_EVENT_FOR_ME;
 
        ret = calendar_record_create(_calendar_event._uri ,out_record);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("calendar_record_create(%d)", ret);
                return CALENDAR_ERROR_OUT_OF_MEMORY;
        }
@@ -282,11 +281,9 @@ time_t __get_time_diff(char *old_tzid, calendar_time_s *old, char *new_tzid, cal
        RETV_IF(NULL == new, CALENDAR_ERROR_INVALID_PARAMETER);
 
        time_t diff = 0;
-       switch (old->type)
-       {
+       switch (old->type) {
        case CALENDAR_TIME_UTIME:
-               switch (new->type)
-               {
+               switch (new->type) {
                case CALENDAR_TIME_UTIME:
                        DBG("%lld - %lld", old->time.utime, new->time.utime);
                        diff = old->time.utime - new->time.utime;
@@ -300,8 +297,7 @@ time_t __get_time_diff(char *old_tzid, calendar_time_s *old, char *new_tzid, cal
                }
                break;
        case CALENDAR_TIME_LOCALTIME:
-               switch (new->type)
-               {
+               switch (new->type) {
                case CALENDAR_TIME_UTIME:
                        DBG("type is changed(%d) -> (%d)", old->type, new->type);
                        diff = cal_time_convert_itol(old_tzid,
@@ -350,15 +346,13 @@ static int __get_time_shifted_field(char *old_field, int old_type, int new_type,
        for (i = 0; i < len_t; i++) {
                int y = 0, m = 0, d = 0;
                int h = 0, n = 0, s = 0;
-               switch (old_type)
-               {
+               switch (old_type) {
                case CALENDAR_TIME_UTIME:
                        sscanf(t[i],  "%04d%02d%02dT%02d%02d%02dZ", &y, &m, &d, &h, &n, &s);
                        break;
 
                case CALENDAR_TIME_LOCALTIME:
-                       switch (strlen(t[i]))
-                       {
+                       switch (strlen(t[i])) {
                        case 8: // YYYYMMDD
                                sscanf(t[i],  "%04d%02d%02d", &y, &m, &d);
                                break;
@@ -378,11 +372,10 @@ static int __get_time_shifted_field(char *old_field, int old_type, int new_type,
                tm.tm_sec = s;
 
                char buf[32] = {0};
-               switch (new_type)
-               {
+               switch (new_type) {
                case CALENDAR_TIME_UTIME:
-                       switch (strlen(t[i])) // check original type
-                       {
+                       switch (strlen(t[i])) {
+                               // check original type
                        case 8: // YYYYMMDD
                        case 15: //YYYYMMDDTHHMMSS
                                tt = timelocal(&tm) - time_diff;
@@ -404,8 +397,7 @@ static int __get_time_shifted_field(char *old_field, int old_type, int new_type,
                        break;
 
                case CALENDAR_TIME_LOCALTIME:
-                       switch (strlen(t[i]))
-                       {
+                       switch (strlen(t[i])) {
                        case 8: // YYYYMMDD
                                tt = timegm(&tm) - time_diff;
                                gmtime_r(&tt, &tm);
@@ -526,8 +518,7 @@ static int __update_record(calendar_record_h record, int is_dirty_in_time)
                return CALENDAR_ERROR_PERMISSION_DENIED;
        }
 
-       if (event->common.properties_flags != NULL)
-       {
+       if (event->common.properties_flags) {
                if (DIRTY_INIT == is_dirty_in_time) {
                        is_dirty_in_time = __is_dirty_in_time(record);
                }
@@ -687,8 +678,7 @@ static int __update_record(calendar_record_h record, int is_dirty_in_time)
                cal_db_util_stmt_bind_text(stmt, index, event->organizer_email);
        index++;
 
-       if (CALENDAR_TIME_LOCALTIME == event->start.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == event->start.type) {
                snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                event->start.time.date.year,
                                event->start.time.date.month,
@@ -704,8 +694,7 @@ static int __update_record(calendar_record_h record, int is_dirty_in_time)
                cal_db_util_stmt_bind_text(stmt, index, event->start_tzid);
        index++;
 
-       if (CALENDAR_TIME_LOCALTIME == event->end.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == event->end.type) {
                snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                event->end.time.date.year,
                                event->end.time.date.month,
@@ -864,27 +853,22 @@ static int _cal_db_event_add_exdate(int original_event_id, char* recurrence_id)
        const unsigned char *temp = NULL;
        int len = 0;
        char *exdate = NULL;
-       if (CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       if (CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                temp = sqlite3_column_text(stmt, 0);
-               if (NULL == temp || strlen((char *)temp) < 1)
-               {
+               if (NULL == temp || strlen((char *)temp) < 1) {
                        exdate = strdup(recurrence_id);
                        DBG("append first exdate[%s]", exdate);
                }
-               else
-               {
-                       if (strstr((char *)temp, recurrence_id))
-                       {
+               else {
+                       if (strstr((char *)temp, recurrence_id)) {
                                DBG("warn: recurrence id already is registered to exdate");
                                sqlite3_finalize(stmt);
                                return CALENDAR_ERROR_NONE;
                        }
                        len = strlen((const char *)temp) + strlen(recurrence_id) + 2;
                        exdate = calloc(len, sizeof(char));
-                       if (NULL == exdate)
-                       {
-                               ERR("calloc() failed");
+                       if (NULL == exdate) {
+                               ERR("calloc() Fail");
                                sqlite3_finalize(stmt);
                                return CALENDAR_ERROR_DB_FAILED;
                        }
@@ -892,8 +876,7 @@ static int _cal_db_event_add_exdate(int original_event_id, char* recurrence_id)
                        DBG("append [%s] to aleady has exdate [%s]", temp, recurrence_id);
                }
        }
-       else
-       {
+       else {
                DBG("Failed to get exdate: event_id(%d)", original_event_id);
        }
        sqlite3_finalize(stmt);
@@ -957,15 +940,13 @@ int cal_db_event_delete_record(int id)
        }
 
        //access control
-       if (cal_access_control_have_write_permission(calendar_book_id) == false)
-       {
-               ERR("fail");
+       if (cal_access_control_have_write_permission(calendar_book_id) == false) {
+               ERR("Fail");
                CAL_FREE(recurrence_id);
                return CALENDAR_ERROR_PERMISSION_DENIED;
        }
 
-       if (0 < original_event_id)
-       {
+       if (0 < original_event_id) {
                // start:add record to exdate if this record is exception mod.
                _cal_db_event_add_exdate(original_event_id, recurrence_id);
        }
@@ -1058,12 +1039,10 @@ static int _cal_db_event_get_all_records(int offset, int limit, calendar_list_h*
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (0 < offset)
-       {
+       if (0 < offset) {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
        }
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
        }
 
@@ -1083,8 +1062,7 @@ static int _cal_db_event_get_all_records(int offset, int limit, calendar_list_h*
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                int exception=0, extended=0;
                // stmt -> record
@@ -1103,19 +1081,13 @@ static int _cal_db_event_get_all_records(int offset, int limit, calendar_list_h*
                int record_id = 0;
                cal_event_s* pevent = (cal_event_s*) record;
                calendar_record_get_int(record, _calendar_event.id, &record_id);
-               if (calendar_record_get_int(record, _calendar_event.has_attendee,&has_attendee) == CALENDAR_ERROR_NONE)
-               {
+               if (calendar_record_get_int(record, _calendar_event.has_attendee,&has_attendee) == CALENDAR_ERROR_NONE) {
                        if (has_attendee == 1)
-                       {
                                cal_db_attendee_get_records(record_id, pevent->attendee_list);
-                       }
                }
-               if (calendar_record_get_int(record, _calendar_event.has_alarm,&has_alarm) == CALENDAR_ERROR_NONE)
-               {
+               if (calendar_record_get_int(record, _calendar_event.has_alarm,&has_alarm) == CALENDAR_ERROR_NONE) {
                        if (has_alarm == 1)
-                       {
                                cal_db_alarm_get_records(record_id, pevent->alarm_list);
-                       }
                }
 
                if (exception == 1)
@@ -1151,39 +1123,32 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
        int i = 0;
        char *table_name;
 
-       if (NULL == query || NULL == out_list)
-       {
+       if (NULL == query || NULL == out_list) {
                ERR("Invalid parameter");
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
                //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
                        ERR("filter create fail");
                        return ret;
@@ -1195,24 +1160,21 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
 
        char *query_str = NULL;
        // query - projection
-       if (projection)
-       {
+       if (projection) {
                cal_db_append_string(&query_str, "SELECT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
                cal_db_append_string(&query_str, table_name);
                CAL_FREE(projection);
        }
-       else
-       {
+       else {
                cal_db_append_string(&query_str, "SELECT * FROM");
                cal_db_append_string(&query_str, table_name);
        }
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -1221,8 +1183,7 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
        // ORDER
        char *order = NULL;
        ret = cal_db_query_create_order(query, condition, &order);
-       if (order)
-       {
+       if (order) {
                cal_db_append_string(&query_str, order);
                CAL_FREE(order);
        }
@@ -1230,13 +1191,11 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
 
        // limit, offset
        char buf[32] = {0};
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (0 < offset)
-               {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -1258,20 +1217,16 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
        }
 
        // bind text
-       if (bind_text)
-       {
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+       if (bind_text) {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
 
        //
        ret = calendar_list_create(&list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -1281,8 +1236,7 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
                return ret;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                int exception = 1, extended = 1;
                int attendee = 1, alarm = 1;
@@ -1291,8 +1245,7 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
                ret = calendar_record_create(_calendar_event._uri,&record);
                if (CALENDAR_ERROR_NONE != ret) {
                        calendar_list_destroy(list, true);
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -1307,31 +1260,26 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
                        cal_event_s *event = NULL;
                        _cal_db_event_get_stmt(stmt,true,record, &exception, &extended);
                        event = (cal_event_s*)(record);
-                       if (event)
-                       {
+                       if (event) {
                                attendee = event->has_attendee;
                                alarm = event->has_alarm;
                        }
                }
 
                // child
-               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_CALENDAR_ALARM) == true && alarm == 1)
-               {
+               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_CALENDAR_ALARM) == true && alarm == 1) {
                        cal_event_s* pevent = (cal_event_s*) record;
                        cal_db_alarm_get_records(pevent->index, pevent->alarm_list);
                }
-               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE) == true && attendee == 1)
-               {
+               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE) == true && attendee == 1) {
                        cal_event_s* pevent = (cal_event_s*) record;
                        cal_db_attendee_get_records(pevent->index, pevent->attendee_list);
                }
-               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_EXCEPTION) == true && exception ==1)
-               {
+               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_EXCEPTION) == true && exception ==1) {
                        cal_event_s* pevent = (cal_event_s*) record;
                        _cal_db_event_exception_get_records(pevent->index, pevent->exception_list);
                }
-               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_EXTENDED) == true && extended ==1)
-               {
+               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_EXTENDED) == true && extended ==1) {
                        cal_event_s* pevent = (cal_event_s*) record;
                        cal_db_extended_get_records(pevent->index, CALENDAR_RECORD_TYPE_EVENT, pevent->extended_list);
                }
@@ -1342,8 +1290,7 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
                        calendar_list_destroy(list, true);
                        calendar_record_destroy(record, true);
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -1353,8 +1300,7 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
                }
        }
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -1377,27 +1323,23 @@ static int _cal_db_event_insert_records(const calendar_list_h list, int** ids)
        int *id = NULL;
 
        ret = calendar_list_get_count(list, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list get error");
                return ret;
        }
 
        id = calloc(1, sizeof(int)*count);
 
-       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                CAL_FREE(id);
                return ret;
        }
-       do
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       do {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_event_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                CAL_FREE(id);
@@ -1405,14 +1347,12 @@ static int _cal_db_event_insert_records(const calendar_list_h list, int** ids)
                        }
                }
                i++;
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
-       if (ids)
-       {
+       if (ids) {
                *ids = id;
        }
-       else
-       {
+       else {
                CAL_FREE(id);
        }
 
@@ -1425,21 +1365,18 @@ static int _cal_db_event_update_records(const calendar_list_h list)
        int ret = 0;
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                return ret;
        }
-       do
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       do {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_event_update_record(record) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                return CALENDAR_ERROR_DB_FAILED;
                        }
                }
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
        return CALENDAR_ERROR_NONE;
 }
@@ -1449,12 +1386,10 @@ static int _cal_db_event_delete_records(int ids[], int count)
        int ret = CALENDAR_ERROR_NONE;
        int i = 0;
 
-       for(i = 0; i < count; i++)
-       {
+       for(i = 0; i < count; i++) {
                ret = _cal_db_event_delete_record(ids[i]);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
-                       ERR("delete failed");
+               if (CALENDAR_ERROR_NONE != ret) {
+                       ERR("delete Fail");
                        return ret;
                }
        }
@@ -1472,8 +1407,7 @@ static int _cal_db_event_get_count(int *out_count)
        int ret = 0;
        int count = 0;
        ret = cal_db_util_query_get_first_int_result(query_str, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("cal_db_util_query_get_first_int_result() failed");
                CAL_FREE(query_str);
                return ret;
@@ -1496,31 +1430,25 @@ static int _cal_db_event_get_count_with_query(calendar_query_h query, int *out_c
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
                //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
                        ERR("filter create fail");
                        return ret;
@@ -1534,8 +1462,7 @@ static int _cal_db_event_get_count_with_query(calendar_query_h query, int *out_c
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str,  "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -1544,11 +1471,9 @@ static int _cal_db_event_get_count_with_query(calendar_query_h query, int *out_c
 
        // query
        ret = cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("cal_db_util_query_get_first_int_result() failed");
-               if (bind_text)
-               {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -1558,8 +1483,7 @@ static int _cal_db_event_get_count_with_query(calendar_query_h query, int *out_c
        DBG("count(%d) str[%s]", count, query_str);
 
        if (out_count) *out_count = count;
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -1586,13 +1510,11 @@ static int _cal_db_event_replace_record(calendar_record_h record, int id)
        event->index = id;
 
        // access control
-       if (cal_access_control_have_write_permission(event->calendar_id) == false)
-       {
+       if (cal_access_control_have_write_permission(event->calendar_id) == false) {
                ERR("cal_access_control_have_write_permission() failed");
                return CALENDAR_ERROR_PERMISSION_DENIED;
        }
-       if (event->common.properties_flags != NULL)
-       {
+       if (event->common.properties_flags != NULL) {
                return _cal_db_event_update_dirty(record, -1);
        }
        has_alarm = cal_db_alarm_has_alarm(event->alarm_list);
@@ -1724,8 +1646,7 @@ static int _cal_db_event_replace_record(calendar_record_h record, int id)
                cal_db_util_stmt_bind_text(stmt, index, event->organizer_email);
        index++;
 
-       if (CALENDAR_TIME_LOCALTIME == event->start.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == event->start.type) {
                snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                event->start.time.date.year,
                                event->start.time.date.month,
@@ -1741,8 +1662,7 @@ static int _cal_db_event_replace_record(calendar_record_h record, int id)
                cal_db_util_stmt_bind_text(stmt, index, event->start_tzid);
        index++;
 
-       if (CALENDAR_TIME_LOCALTIME == event->end.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == event->end.type) {
                snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                event->end.time.date.year,
                                event->end.time.date.month,
@@ -1839,30 +1759,25 @@ static int _cal_db_event_replace_records(const calendar_list_h list, int ids[],
        int i = 0;
        int ret = 0;
 
-       if (NULL == list)
-       {
+       if (NULL == list) {
                ERR("Invalid argument: list is NULL");
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                return ret;
        }
 
-       for (i = 0; i < count; i++)
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       for (i = 0; i < count; i++) {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_event_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                return CALENDAR_ERROR_DB_FAILED;
                        }
                }
-               if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
-               {
+               if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list)) {
                        break;
                }
        }
@@ -1929,13 +1844,11 @@ static void _cal_db_event_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calenda
        event->is_deleted = sqlite3_column_int(stmt,count++);
        event->start.type = sqlite3_column_int(stmt,count++);
 
-       if (event->start.type == CALENDAR_TIME_UTIME)
-       {
+       if (event->start.type == CALENDAR_TIME_UTIME) {
                event->start.time.utime = sqlite3_column_int64(stmt,count++);
                count++; // dtstart_datetime
        }
-       else
-       {
+       else {
                count++; // dtstart_utime
                temp = sqlite3_column_text(stmt, count++);
                if (temp) {
@@ -1950,13 +1863,11 @@ static void _cal_db_event_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calenda
        event->start_tzid = SAFE_STRDUP(temp);
 
        event->end.type = sqlite3_column_int(stmt, count++);
-       if (event->end.type == CALENDAR_TIME_UTIME)
-       {
+       if (event->end.type == CALENDAR_TIME_UTIME) {
                event->end.time.utime = sqlite3_column_int64(stmt,count++);
                count++; // dtend_datetime
        }
-       else
-       {
+       else {
                count++; // dtend_utime
                temp = sqlite3_column_text(stmt, count++);
                if (temp) {
@@ -1990,11 +1901,11 @@ static void _cal_db_event_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calenda
        event->sync_data4 = SAFE_STRDUP(temp);
 
        //has_exception
-       if (exception != NULL)
+       if (exception)
                *exception = sqlite3_column_int(stmt,count++);
 
        //has_extended
-       if (extended != NULL)
+       if (extended)
                *extended = sqlite3_column_int(stmt,count++);
 
        event->freq = sqlite3_column_int(stmt, count++);
@@ -2012,8 +1923,7 @@ static void _cal_db_event_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calenda
                event->range_type = sqlite3_column_int(stmt, count++);
                event->until.type = sqlite3_column_int(stmt, count++);
 
-               switch (event->until.type)
-               {
+               switch (event->until.type) {
                case CALENDAR_TIME_UTIME:
                        event->until.time.utime = sqlite3_column_int64(stmt, count++);
                        count++; // datetime
@@ -2076,8 +1986,7 @@ static void _cal_db_event_get_property_stmt(sqlite3_stmt *stmt,
 
        event = (cal_event_s*)(record);
 
-       switch (property)
-       {
+       switch (property) {
        case CAL_PROPERTY_EVENT_ID:
                event->index = sqlite3_column_int(stmt, *stmt_count);
                break;
@@ -2244,14 +2153,12 @@ static void _cal_db_event_get_property_stmt(sqlite3_stmt *stmt,
                break;
        case CAL_PROPERTY_EVENT_START:
                event->start.type = sqlite3_column_int(stmt,*stmt_count);
-               if (event->start.type == CALENDAR_TIME_UTIME)
-               {
+               if (event->start.type == CALENDAR_TIME_UTIME) {
                        *stmt_count = *stmt_count+1;
                        event->start.time.utime = sqlite3_column_int64(stmt,*stmt_count);
                        *stmt_count = *stmt_count+1; // dtstart_datetime
                }
-               else
-               {
+               else {
                        *stmt_count = *stmt_count+1;
                        *stmt_count = *stmt_count+1;
                        temp = sqlite3_column_text(stmt, *stmt_count);
@@ -2270,14 +2177,12 @@ static void _cal_db_event_get_property_stmt(sqlite3_stmt *stmt,
        case CAL_PROPERTY_EVENT_END:
                //!!
                event->end.type = sqlite3_column_int(stmt, *stmt_count);
-               if (event->end.type == CALENDAR_TIME_UTIME)
-               {
+               if (event->end.type == CALENDAR_TIME_UTIME) {
                        *stmt_count = *stmt_count+1;
                        event->end.time.utime = sqlite3_column_int64(stmt,*stmt_count);
                        *stmt_count = *stmt_count+1; // dtstart_datetime
                }
-               else
-               {
+               else {
                        *stmt_count = *stmt_count+1; // dtend_utime
                        *stmt_count = *stmt_count+1;
                        temp = sqlite3_column_text(stmt, *stmt_count);
@@ -2311,8 +2216,7 @@ static void _cal_db_event_get_projection_stmt(sqlite3_stmt *stmt,
        int i=0;
        int stmt_count = 0;
 
-       for(i=0;i<projection_count;i++)
-       {
+       for(i=0;i<projection_count;i++) {
                _cal_db_event_get_property_stmt(stmt,projection[i],&stmt_count,record);
        }
 }
@@ -2409,16 +2313,13 @@ static int _cal_db_event_update_dirty(calendar_record_h record, int is_dirty_in_
 
        property_info = cal_view_get_property_info(_record->view_uri, &property_info_count);
 
-       for(i=0;i<property_info_count;i++)
-       {
-               if (false == cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY))
-               {
+       for(i=0;i<property_info_count;i++) {
+               if (false == cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY)) {
                        continue;
                }
 
                //DBG("%d",property_info[i].property_id);
-               if (property_info[i].property_id == CAL_PROPERTY_EVENT_EXDATE)
-               {
+               if (property_info[i].property_id == CAL_PROPERTY_EVENT_EXDATE) {
                        int calendar_id = 0;
                        int account_id = 0;
                        calendar_book_sync_event_type_e sync_event_type = CALENDAR_BOOK_SYNC_EVENT_FOR_ME;
@@ -2442,8 +2343,7 @@ static int _cal_db_event_update_dirty(calendar_record_h record, int is_dirty_in_
                        ret = calendar_record_get_str_p(original_record,property_info[i].property_id,&original_exdate);
                        if (CALENDAR_ERROR_NONE != ret)
                                continue;
-                       if (sync_event_type == CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN)
-                       {
+                       if (sync_event_type == CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN) {
                                ret = _cal_db_event_exdate_insert_normal(event_id, original_exdate, record_exdate, NULL, NULL);
                                WARN_IF(CALENDAR_ERROR_NONE != ret, "%s->%s",original_exdate,record_exdate);
 
@@ -2460,8 +2360,7 @@ static int _cal_db_event_update_dirty(calendar_record_h record, int is_dirty_in_
                        if (CALENDAR_ERROR_NONE != ret)
                                continue;
                }
-               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
-               {
+               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true) {
                        int tmp=0;
                        ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
                        if (CALENDAR_ERROR_NONE != ret)
@@ -2470,8 +2369,7 @@ static int _cal_db_event_update_dirty(calendar_record_h record, int is_dirty_in_
                        if (CALENDAR_ERROR_NONE != ret)
                                continue;
                }
-               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
-               {
+               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true) {
                        char *tmp=NULL;
                        ret = calendar_record_get_str_p(record,property_info[i].property_id,&tmp);
                        if (CALENDAR_ERROR_NONE != ret)
@@ -2480,8 +2378,7 @@ static int _cal_db_event_update_dirty(calendar_record_h record, int is_dirty_in_
                        if (CALENDAR_ERROR_NONE != ret)
                                continue;
                }
-               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
-               {
+               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
                        double tmp=0;
                        ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
                        if (CALENDAR_ERROR_NONE != ret)
@@ -2490,8 +2387,7 @@ static int _cal_db_event_update_dirty(calendar_record_h record, int is_dirty_in_
                        if (CALENDAR_ERROR_NONE != ret)
                                continue;
                }
-               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
-               {
+               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true) {
                        long long int tmp=0;
                        ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
                        if (CALENDAR_ERROR_NONE != ret)
@@ -2500,8 +2396,7 @@ static int _cal_db_event_update_dirty(calendar_record_h record, int is_dirty_in_
                        if (CALENDAR_ERROR_NONE != ret)
                                continue;
                }
-               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
-               {
+               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
                        calendar_time_s tmp = {0,};
                        ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
                        if (CALENDAR_ERROR_NONE != ret)
@@ -2571,8 +2466,7 @@ static int _cal_db_event_exception_get_records(int original_id, cal_list_s *list
 
                cal_rrule_s *rrule = NULL;
                cal_event_s *event = (cal_event_s *)record;
-               if (cal_db_rrule_get_rrule(event->index, &rrule) == CALENDAR_ERROR_NONE)
-               {
+               if (cal_db_rrule_get_rrule(event->index, &rrule) == CALENDAR_ERROR_NONE) {
                        cal_db_rrule_set_rrule_to_event(rrule, record);
                        CAL_FREE(rrule);
                }
@@ -2736,7 +2630,7 @@ static int _cal_db_event_exception_update(cal_list_s *exception_list_s, int orig
 
        if (id_list) {
                GList * tmp_list = g_list_first(id_list);
-               while(tmp_list) {
+               while (tmp_list) {
                        int tmp = GPOINTER_TO_INT(tmp_list->data);
                        char query[CAL_DB_SQL_MAX_LEN] = {0};
                        cal_db_util_error_e dbret = CAL_DB_OK;
@@ -2803,13 +2697,11 @@ static int _cal_db_event_exdate_insert_normal(int event_id, const char* original
        int len1 = 0, len2 = 0, i = 0, j = 0;
 
        int input_ver = cal_db_util_get_next_ver();
-       if (exdate != NULL && 0 < strlen(exdate))
-       {
+       if (exdate != NULL && 0 < strlen(exdate)) {
                patterns1 = g_strsplit_set(exdate, " ,", -1);
                len1 = g_strv_length(patterns1);
        }
-       if (original_exdate != NULL && 0 < strlen(original_exdate))
-       {
+       if (original_exdate && 0 < strlen(original_exdate)) {
                patterns2 = g_strsplit_set(original_exdate, " ,", -1);
                len2 = g_strv_length(patterns2);
        }
@@ -2825,25 +2717,21 @@ static int _cal_db_event_exdate_insert_normal(int event_id, const char* original
                }
                bool bFind = false;
                cal_db_util_error_e dbret = CAL_DB_OK;
-               for(j = 0; j < len2; j++)
-               {
+               for(j = 0; j < len2; j++) {
                        if (NULL == patterns2[j]) {
                                ERR("original exdate is NULL");
                                continue;
                        }
-                       if (CAL_STRING_EQUAL == strcmp(patterns1[i], patterns2[j]))
-                       {
+                       if (CAL_STRING_EQUAL == strcmp(patterns1[i], patterns2[j])) {
                                bFind = true;
                                break;
                        }
                }
-               if (bFind == false)
-               {
+               if (bFind == false) {
                        char query[CAL_DB_SQL_MAX_LEN] = {0};
                        long long int start_utime = 0;
                        char datetime[16] = {0};
-                       if (strlen("YYYYMMDD") < strlen(patterns1[i]))
-                       {
+                       if (strlen("YYYYMMDD") < strlen(patterns1[i])) {
                                //DBG("NORMAL instance");
                                int y, mon, d, h, min, s;
                                sscanf(patterns1[i], "%04d%02d%02dT%02d%02d%02dZ",
@@ -2852,8 +2740,7 @@ static int _cal_db_event_exdate_insert_normal(int event_id, const char* original
 
                                //DBG("(%lld)", start_utime);
                        }
-                       else
-                       {
+                       else {
                                //DBG("ALLDAY instance");
                                snprintf(datetime, sizeof(datetime),
                                                "%s", patterns1[i]);
index 8e2602a..5f6c283 100644 (file)
@@ -88,9 +88,8 @@ static int _cal_db_extended_get_record(int id, calendar_record_h* out_record)
        int ret = 0;
 
        ret = calendar_record_create(_calendar_extended_property._uri ,out_record);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("record create fail");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("record create Fail");
                return CALENDAR_ERROR_OUT_OF_MEMORY;
        }
 
@@ -138,8 +137,7 @@ static int _cal_db_extended_update_record(calendar_record_h record)
 
        RETV_IF(NULL == extended_info, CALENDAR_ERROR_INVALID_PARAMETER);
 
-       if (extended_info->common.properties_flags != NULL)
-       {
+       if (extended_info->common.properties_flags) {
                return _cal_db_extended_update_projection(record);
        }
 
@@ -212,8 +210,7 @@ static int _cal_db_extended_replace_record(calendar_record_h record, int id)
        RETV_IF(NULL == extended_info, CALENDAR_ERROR_INVALID_PARAMETER);
        extended_info->id = id;
 
-       if (extended_info->common.properties_flags != NULL)
-       {
+       if (extended_info->common.properties_flags) {
                return _cal_db_extended_update_projection(record);
        }
 
@@ -267,12 +264,10 @@ static int _cal_db_extended_get_all_records(int offset, int limit, calendar_list
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (0 < offset)
-       {
+       if (0 < offset) {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
        }
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
        }
        snprintf(query, sizeof(query), "SELECT * FROM %s %s %s", CAL_TABLE_EXTENDED,limitquery,offsetquery);
@@ -286,8 +281,7 @@ static int _cal_db_extended_get_all_records(int offset, int limit, calendar_list
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(_calendar_extended_property._uri,&record);
@@ -328,12 +322,10 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
        que = (cal_query_s *)query;
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
-                       ERR("filter create fail");
+               if (CALENDAR_ERROR_NONE != ret) {
+                       ERR("filter create Fail");
                        return ret;
                }
        }
@@ -342,23 +334,20 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
        ret = cal_db_query_create_projection(query, &projection);
 
        // query - projection
-       if (projection)
-       {
+       if (projection) {
                cal_db_append_string(&query_str, "SELECT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
                cal_db_append_string(&query_str, CAL_TABLE_EXTENDED);
                CAL_FREE(projection);
        }
-       else
-       {
+       else {
                cal_db_append_string(&query_str, "SELECT * FROM");
                cal_db_append_string(&query_str, CAL_TABLE_EXTENDED);
        }
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE");
                cal_db_append_string(&query_str, condition);
                CAL_FREE(condition);
@@ -366,19 +355,16 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
 
        // ORDER
        ret = cal_db_query_create_order(query, condition, &order);
-       if (order)
-       {
+       if (order) {
                cal_db_append_string(&query_str, order);
                CAL_FREE(order);
        }
 
        char buf[32] = {0};
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
-               if (0 < offset)
-               {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -400,20 +386,16 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
        DBG("%s",query_str);
 
        // bind text
-       if (bind_text)
-       {
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+       if (bind_text) {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
 
        //
        ret = calendar_list_create(out_list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -423,8 +405,7 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
                return ret;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(_calendar_extended_property._uri,&record);
@@ -432,8 +413,7 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
                        calendar_list_destroy(*out_list, true);
                        *out_list = NULL;
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -441,8 +421,7 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
                        sqlite3_finalize(stmt);
                        return ret;
                }
-               if (0 < que->projection_count)
-               {
+               if (0 < que->projection_count) {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
@@ -450,8 +429,7 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
                                        que->projection, que->projection_count,
                                        record);
                }
-               else
-               {
+               else {
                        _cal_db_extended_get_stmt(stmt,record);
                }
 
@@ -461,8 +439,7 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
                        *out_list = NULL;
                        calendar_record_destroy(record, true);
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -472,8 +449,7 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
                }
        }
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -491,27 +467,23 @@ static int _cal_db_extended_insert_records(const calendar_list_h list, int** ids
        int *id = NULL;
 
        ret = calendar_list_get_count(list, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list get error");
                return ret;
        }
 
        id = calloc(1, sizeof(int)*count);
 
-       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                CAL_FREE(id);
                return ret;
        }
-       do
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       do {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_extended_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                CAL_FREE(id);
@@ -519,14 +491,12 @@ static int _cal_db_extended_insert_records(const calendar_list_h list, int** ids
                        }
                }
                i++;
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
-       if (ids)
-       {
+       if (ids) {
                *ids = id;
        }
-       else
-       {
+       else {
                CAL_FREE(id);
        }
 
@@ -539,21 +509,18 @@ static int _cal_db_extended_update_records(const calendar_list_h list)
        int ret = 0;
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                return ret;
        }
-       do
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       do {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_extended_update_record(record) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                return CALENDAR_ERROR_DB_FAILED;
                        }
                }
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
        return CALENDAR_ERROR_NONE;
 }
@@ -561,11 +528,9 @@ static int _cal_db_extended_update_records(const calendar_list_h list)
 static int _cal_db_extended_delete_records(int ids[], int count)
 {
        int i=0;
-       for(i=0;i<count;i++)
-       {
-               if (_cal_db_extended_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
-               {
-                       ERR("delete failed");
+       for(i=0;i<count;i++) {
+               if (_cal_db_extended_delete_record(ids[i]) != CALENDAR_ERROR_NONE) {
+                       ERR("delete Fail");
                        return CALENDAR_ERROR_DB_FAILED;
                }
        }
@@ -578,30 +543,25 @@ static int _cal_db_extended_replace_records(const calendar_list_h list, int ids[
        int i;
        int ret = 0;
 
-       if (NULL == list)
-       {
+       if (NULL == list) {
                ERR("Invalid argument: list is NULL");
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                return ret;
        }
 
-       for (i = 0; i < count; i++)
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       for (i = 0; i < count; i++) {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_extended_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                return CALENDAR_ERROR_DB_FAILED;
                        }
                }
-               if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
-               {
+               if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list)) {
                        break;
                }
        }
@@ -620,9 +580,8 @@ static int _cal_db_extended_get_count(int *out_count)
        snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_TABLE_EXTENDED);
 
        ret = cal_db_util_query_get_first_int_result(query, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                return ret;
        }
        DBG("%s=%d",query,count);
@@ -643,22 +602,18 @@ static int _cal_db_extended_get_count_with_query(calendar_query_h query, int *ou
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EXTENDED))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EXTENDED)) {
                table_name = SAFE_STRDUP(CAL_TABLE_EXTENDED);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
                        ERR("filter create fail");
                        return ret;
@@ -671,8 +626,7 @@ static int _cal_db_extended_get_count_with_query(calendar_query_h query, int *ou
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE");
                cal_db_append_string(&query_str, condition);
                CAL_FREE(condition);
@@ -680,11 +634,9 @@ static int _cal_db_extended_get_count_with_query(calendar_query_h query, int *ou
 
        // query
        ret = cal_db_util_query_get_first_int_result(query_str, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -695,8 +647,7 @@ static int _cal_db_extended_get_count_with_query(calendar_query_h query, int *ou
 
        *out_count = count;
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -727,8 +678,7 @@ static void _cal_db_extended_get_property_stmt(sqlite3_stmt *stmt,
        cal_extended_s* extended =  (cal_extended_s*)(record);
        const unsigned char *temp;
 
-       switch (property)
-       {
+       switch (property) {
        case CAL_PROPERTY_EXTENDED_ID:
                extended->id = sqlite3_column_int(stmt, stmt_count);
                break;
@@ -760,8 +710,7 @@ static void _cal_db_extended_get_projection_stmt(sqlite3_stmt *stmt,
 {
        int i=0;
 
-       for(i=0;i<projection_count;i++)
-       {
+       for(i=0;i<projection_count;i++) {
                _cal_db_extended_get_property_stmt(stmt,projection[i],i,record);
        }
 }
index f131fdc..edbbc58 100644 (file)
@@ -129,8 +129,7 @@ static int _cal_db_instance_allday_get_all_records(int offset, int limit, calend
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(_calendar_instance_localtime_calendar_book._uri,&record);
@@ -173,27 +172,22 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
                //table_name = SAFE_STRDUP(CAL_TABLE_ALLDAY_INSTANCE);
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
                        ERR("filter create fail");
                        return ret;
@@ -205,24 +199,21 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
 
        char *query_str = NULL;
        // query - projection
-       if (projection)
-       {
+       if (projection) {
                cal_db_append_string(&query_str, "SELECT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
                cal_db_append_string(&query_str, table_name);
                CAL_FREE(projection);
        }
-       else
-       {
+       else {
                cal_db_append_string(&query_str, "SELECT * FROM");
                cal_db_append_string(&query_str, table_name);
        }
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str,  "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -231,8 +222,7 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
        // ORDER
        char *order = NULL;
        ret = cal_db_query_create_order(query, condition, &order);
-       if (order)
-       {
+       if (order) {
                cal_db_append_string(&query_str, order);
                CAL_FREE(order);
        }
@@ -240,13 +230,11 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
 
        // limit, offset
        char buf[32] = {0};
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (0 < offset)
-               {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -268,21 +256,17 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
        DBG("%s",query_str);
 
        // bind text
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_length(bind_text);
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
 
        //
        ret = calendar_list_create(out_list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -292,8 +276,7 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
                return ret;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(que->view_uri,&record);
@@ -301,8 +284,7 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
                        calendar_list_destroy(*out_list, true);
                        *out_list = NULL;
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -310,17 +292,11 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
                        CAL_FREE(query_str);
                        return ret;
                }
-               if (0 < que->projection_count)
-               {
-                       cal_record_set_projection(record,
-                                       que->projection, que->projection_count, que->property_count);
-
-                       _cal_db_instance_allday_get_projection_stmt(stmt,
-                                       que->projection, que->projection_count,
-                                       record);
+               if (0 < que->projection_count) {
+                       cal_record_set_projection(record, que->projection, que->projection_count, que->property_count);
+                       _cal_db_instance_allday_get_projection_stmt(stmt, que->projection, que->projection_count, record);
                }
-               else
-               {
+               else {
                        _cal_db_instance_allday_get_stmt(stmt,record);
                }
 
@@ -330,8 +306,7 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
                        *out_list = NULL;
                        calendar_record_destroy(record, true);
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -341,8 +316,7 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
                }
        }
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -365,7 +339,7 @@ static int _cal_db_instance_allday_get_count(int *out_count)
        int count = 0;
        ret = cal_db_util_query_get_first_int_result(query_str, NULL, &count);
        if (CALENDAR_ERROR_NONE != ret) {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                CAL_FREE(query_str);
                return ret;
        }
@@ -387,27 +361,22 @@ static int _cal_db_instance_allday_get_count_with_query(calendar_query_h query,
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
                //table_name = SAFE_STRDUP(CAL_TABLE_ALLDAY_INSTANCE);
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
                        ERR("filter create fail");
                        return ret;
@@ -421,8 +390,7 @@ static int _cal_db_instance_allday_get_count_with_query(calendar_query_h query,
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -431,11 +399,9 @@ static int _cal_db_instance_allday_get_count_with_query(calendar_query_h query,
 
        // query
        ret = cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -446,8 +412,7 @@ static int _cal_db_instance_allday_get_count_with_query(calendar_query_h query,
 
        if (out_count) *out_count = count;
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -504,8 +469,7 @@ static void _cal_db_instance_allday_get_stmt(sqlite3_stmt *stmt,calendar_record_
        instance->sensitivity = sqlite3_column_int(stmt, count++);
 
        instance->has_rrule = sqlite3_column_int(stmt, count++);
-       if (0 < instance->has_rrule)
-       {
+       if (0 < instance->has_rrule) {
                instance->has_rrule = 1;
        }
 
@@ -530,8 +494,7 @@ static void _cal_db_instance_allday_get_property_stmt(sqlite3_stmt *stmt,
        cal_instance_allday_s* instance =  (cal_instance_allday_s*)(record);
        const unsigned char *temp;
 
-       switch (property)
-       {
+       switch (property) {
        case CAL_PROPERTY_INSTANCE_ALLDAY_START:
                instance->start.type = CALENDAR_TIME_LOCALTIME;
                *stmt_count = *stmt_count+1; // utime
@@ -586,8 +549,7 @@ static void _cal_db_instance_allday_get_property_stmt(sqlite3_stmt *stmt,
                break;
        case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE:
                instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
-               if (0 < instance->has_rrule)
-               {
+               if (0 < instance->has_rrule) {
                        instance->has_rrule = 1;
                }
                break;
@@ -634,8 +596,7 @@ static void _cal_db_instance_allday_get_projection_stmt(sqlite3_stmt *stmt,
        int i=0;
        int stmt_count = 0;
 
-       for(i=0;i<projection_count;i++)
-       {
+       for(i=0;i<projection_count;i++) {
                _cal_db_instance_allday_get_property_stmt(stmt,projection[i],&stmt_count,record);
        }
 }
index 4b9ba62..8482bf7 100755 (executable)
@@ -94,8 +94,7 @@ static int _cal_db_instance_allday_extended_get_all_records(int offset, int limi
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(_calendar_instance_localtime_calendar_book_extended._uri,&record);
@@ -140,11 +139,9 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
        table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
                        ERR("filter create fail");
                        return ret;
@@ -156,24 +153,21 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
 
        char *query_str = NULL;
        // query - projection
-       if (projection)
-       {
+       if (projection) {
                cal_db_append_string(&query_str, "SELECT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
                cal_db_append_string(&query_str, table_name);
                CAL_FREE(projection);
        }
-       else
-       {
+       else {
                cal_db_append_string(&query_str, "SELECT * FROM");
                cal_db_append_string(&query_str, table_name);
        }
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -182,8 +176,7 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
        // ORDER
        char *order = NULL;
        ret = cal_db_query_create_order(query, condition, &order);
-       if (order)
-       {
+       if (order) {
                cal_db_append_string(&query_str, order);
                CAL_FREE(order);
        }
@@ -191,13 +184,11 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
 
        // limit, offset
        char buf[32] = {0};
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (0 < offset)
-               {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -219,21 +210,17 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
        }
 
        // bind text
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_length(bind_text);
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
 
        //
        ret = calendar_list_create(out_list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -243,8 +230,7 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
                return ret;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(que->view_uri,&record);
@@ -252,8 +238,7 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
                        calendar_list_destroy(*out_list, true);
                        *out_list = NULL;
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -274,8 +259,7 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
                        *out_list = NULL;
                        calendar_record_destroy(record, true);
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -285,8 +269,7 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
                }
        }
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -308,9 +291,8 @@ static int _cal_db_instance_allday_extended_get_count(int *out_count)
        int ret = 0;
        int count = 0;
        ret = cal_db_util_query_get_first_int_result(query_str, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                CAL_FREE(query_str);
                return ret;
        }
@@ -335,13 +317,11 @@ static int _cal_db_instance_allday_extended_get_count_with_query(calendar_query_
        table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
-                       ERR("filter create fail");
+                       ERR("filter create Fail");
                        return ret;
                }
        }
@@ -353,8 +333,7 @@ static int _cal_db_instance_allday_extended_get_count_with_query(calendar_query_
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -363,11 +342,9 @@ static int _cal_db_instance_allday_extended_get_count_with_query(calendar_query_
 
        // query
        ret = cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -378,8 +355,7 @@ static int _cal_db_instance_allday_extended_get_count_with_query(calendar_query_
 
        if (out_count) *out_count = count;
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -432,8 +408,7 @@ static void _cal_db_instance_allday_extended_get_stmt(sqlite3_stmt *stmt,calenda
        instance->sensitivity = sqlite3_column_int(stmt, count++);
 
        instance->has_rrule = sqlite3_column_int(stmt, count++);
-       if (0 < instance->has_rrule)
-       {
+       if (0 < instance->has_rrule) {
                instance->has_rrule = 1;
        }
 
@@ -476,8 +451,7 @@ static void _cal_db_instance_allday_extended_get_property_stmt(sqlite3_stmt *stm
        cal_instance_allday_extended_s* instance =  (cal_instance_allday_extended_s*)(record);
        const unsigned char *temp;
 
-       switch (property)
-       {
+       switch (property) {
        case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_START:
                instance->start.type = CALENDAR_TIME_LOCALTIME;
                *stmt_count = *stmt_count+1; // utime
@@ -531,8 +505,7 @@ static void _cal_db_instance_allday_extended_get_property_stmt(sqlite3_stmt *stm
                break;
        case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_RRULE:
                instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
-               if (0 < instance->has_rrule)
-               {
+               if (0 < instance->has_rrule) {
                        instance->has_rrule = 1;
                }
                break;
@@ -602,8 +575,7 @@ static void _cal_db_instance_allday_extended_get_projection_stmt(sqlite3_stmt *s
        int i=0;
        int stmt_count = 0;
 
-       for(i=0;i<projection_count;i++)
-       {
+       for(i=0;i<projection_count;i++) {
                _cal_db_instance_allday_extended_get_property_stmt(stmt,projection[i],&stmt_count,record);
        }
 }
index 69fcddb..75c4a58 100644 (file)
@@ -129,8 +129,7 @@ static int _cal_db_instance_normal_get_all_records(int offset, int limit, calend
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(_calendar_instance_utime_calendar_book._uri,&record);
@@ -172,29 +171,24 @@ 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))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
                //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
-                       ERR("filter create fail");
+                       ERR("filter create Fail");
                        return ret;
                }
        }
@@ -204,24 +198,21 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
 
        char *query_str = NULL;
        // query - projection
-       if (projection)
-       {
+       if (projection) {
                cal_db_append_string(&query_str, "SELECT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
                cal_db_append_string(&query_str, table_name);
                CAL_FREE(projection);
        }
-       else
-       {
+       else {
                cal_db_append_string(&query_str, "SELECT * FROM");
                cal_db_append_string(&query_str, table_name);
        }
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -230,8 +221,7 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
        // ORDER
        char *order = NULL;
        ret = cal_db_query_create_order(query, condition, &order);
-       if (order)
-       {
+       if (order) {
                cal_db_append_string(&query_str, order);
                CAL_FREE(order);
        }
@@ -239,13 +229,11 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
 
        // limit, offset
        char buf[32] = {0};
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (0 < offset)
-               {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -267,21 +255,17 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
        DBG("%s",query_str);
 
        // bind text
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_length(bind_text);
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
 
        //
        ret = calendar_list_create(out_list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -291,8 +275,7 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
                return ret;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(que->view_uri,&record);
@@ -300,16 +283,14 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
                        calendar_list_destroy(*out_list, true);
                        *out_list = NULL;
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
                        sqlite3_finalize(stmt);
                        return ret;
                }
-               if (0 < que->projection_count)
-               {
+               if (0 < que->projection_count) {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
@@ -317,8 +298,7 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
                                        que->projection, que->projection_count,
                                        record);
                }
-               else
-               {
+               else {
                        _cal_db_instance_normal_get_stmt(stmt,record);
                }
 
@@ -328,8 +308,7 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
                        *out_list = NULL;
                        calendar_record_destroy(record, true);
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -339,8 +318,7 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
                }
        }
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -361,9 +339,8 @@ static int _cal_db_instance_normal_get_count(int *out_count)
        int ret = 0;
        int count = 0;
        ret = cal_db_util_query_get_first_int_result(query_str, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                CAL_FREE(query_str);
                return ret;
        }
@@ -385,29 +362,24 @@ 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))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
                //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
-                       ERR("filter create fail");
+                       ERR("filter create Fail");
                        return ret;
                }
        }
@@ -419,8 +391,7 @@ static int _cal_db_instance_normal_get_count_with_query(calendar_query_h query,
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str,  "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -429,11 +400,9 @@ static int _cal_db_instance_normal_get_count_with_query(calendar_query_h query,
 
        // query
        ret = cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -444,8 +413,7 @@ static int _cal_db_instance_normal_get_count_with_query(calendar_query_h query,
        DBG("count(%d) str[%s]", count, query_str);
 
        if (out_count) *out_count = count;
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -486,8 +454,7 @@ static void _cal_db_instance_normal_get_stmt(sqlite3_stmt *stmt, calendar_record
        instance->sensitivity = sqlite3_column_int(stmt, count++);
 
        instance->has_rrule = sqlite3_column_int(stmt, count++);
-       if (0 < instance->has_rrule)
-       {
+       if (0 < instance->has_rrule) {
                instance->has_rrule = 1;
        }
 
@@ -510,8 +477,7 @@ static void _cal_db_instance_normal_get_property_stmt(sqlite3_stmt *stmt,
        cal_instance_normal_s* instance =  (cal_instance_normal_s*)(record);
        const unsigned char *temp;
 
-       switch (property)
-       {
+       switch (property) {
        case CAL_PROPERTY_INSTANCE_NORMAL_START:
                instance->start.type = CALENDAR_TIME_UTIME;
                *stmt_count = *stmt_count+1;
@@ -554,8 +520,7 @@ static void _cal_db_instance_normal_get_property_stmt(sqlite3_stmt *stmt,
                break;
        case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
                instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
-               if (0 < instance->has_rrule)
-               {
+               if (0 < instance->has_rrule) {
                        instance->has_rrule = 1;
                }
                break;
@@ -598,8 +563,7 @@ static void _cal_db_instance_normal_get_projection_stmt(sqlite3_stmt *stmt,
        int i=0;
        int stmt_count = 0;
 
-       for(i=0;i<projection_count;i++)
-       {
+       for(i=0;i<projection_count;i++) {
                _cal_db_instance_normal_get_property_stmt(stmt,projection[i],&stmt_count,record);
        }
 }
index f4692fd..7d33a4a 100755 (executable)
@@ -93,8 +93,7 @@ static int _cal_db_instance_normal_extended_get_all_records(int offset, int limi
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(_calendar_instance_utime_calendar_book_extended._uri,&record);
@@ -139,11 +138,9 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
        table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
                        ERR("filter create fail");
                        return ret;
@@ -155,24 +152,21 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
 
        char *query_str = NULL;
        // query - projection
-       if (projection)
-       {
+       if (projection) {
                cal_db_append_string(&query_str, "SELECT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
                cal_db_append_string(&query_str, table_name);
                CAL_FREE(projection);
        }
-       else
-       {
+       else {
                cal_db_append_string(&query_str, "SELECT * FROM");
                cal_db_append_string(&query_str, table_name);
        }
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -181,8 +175,7 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
        // ORDER
        char *order = NULL;
        ret = cal_db_query_create_order(query, condition, &order);
-       if (order)
-       {
+       if (order) {
                cal_db_append_string(&query_str, order);
                CAL_FREE(order);
        }
@@ -190,13 +183,11 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
 
        // limit, offset
        char buf[32] = {0};
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (0 < offset)
-               {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -218,21 +209,17 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
        }
 
        // bind text
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_length(bind_text);
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
 
        //
        ret = calendar_list_create(out_list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -242,8 +229,7 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
                return ret;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(que->view_uri,&record);
@@ -251,8 +237,7 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
                        calendar_list_destroy(*out_list, true);
                        *out_list = NULL;
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -260,16 +245,14 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
                        return ret;
                }
 
-               if (0 < que->projection_count)
-               {
+               if (0 < que->projection_count) {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
                        _cal_db_instance_normal_extended_get_projection_stmt(stmt,
                                        que->projection, que->projection_count, record);
                }
-               else
-               {
+               else {
                        _cal_db_instance_normal_extended_get_stmt(stmt,record);
                }
 
@@ -279,8 +262,7 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
                        *out_list = NULL;
                        calendar_record_destroy(record, true);
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -290,8 +272,7 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
                }
        }
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -312,9 +293,8 @@ static int _cal_db_instance_normal_extended_get_count(int *out_count)
        int ret = 0;
        int count = 0;
        ret = cal_db_util_query_get_first_int_result(query_str, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                CAL_FREE(query_str);
                return ret;
        }
@@ -338,11 +318,9 @@ static int _cal_db_instance_normal_extended_get_count_with_query(calendar_query_
        table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
                        ERR("filter create fail");
                        return ret;
@@ -356,8 +334,7 @@ static int _cal_db_instance_normal_extended_get_count_with_query(calendar_query_
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -366,11 +343,9 @@ static int _cal_db_instance_normal_extended_get_count_with_query(calendar_query_
 
        // query
        ret = cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -381,8 +356,7 @@ static int _cal_db_instance_normal_extended_get_count_with_query(calendar_query_
        DBG("count(%d) str[%s]", count, query_str);
 
        if (out_count) *out_count = count;
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -423,8 +397,7 @@ static void _cal_db_instance_normal_extended_get_stmt(sqlite3_stmt *stmt,calenda
        instance->sensitivity = sqlite3_column_int(stmt, count++);
 
        instance->has_rrule = sqlite3_column_int(stmt, count++);
-       if (0 < instance->has_rrule)
-       {
+       if (0 < instance->has_rrule) {
                instance->has_rrule = 1;
        }
 
@@ -464,8 +437,7 @@ static void _cal_db_instance_normal_extended_get_property_stmt(sqlite3_stmt *stm
        cal_instance_normal_extended_s* instance =  (cal_instance_normal_extended_s*)(record);
        const unsigned char *temp;
 
-       switch (property)
-       {
+       switch (property) {
        case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_START:
                instance->start.type = CALENDAR_TIME_UTIME;
                *stmt_count = *stmt_count+1;
@@ -509,8 +481,7 @@ static void _cal_db_instance_normal_extended_get_property_stmt(sqlite3_stmt *stm
                break;
        case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE:
                instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
-               if (0 < instance->has_rrule)
-               {
+               if (0 < instance->has_rrule) {
                        instance->has_rrule = 1;
                }
                break;
@@ -576,8 +547,7 @@ static void _cal_db_instance_normal_extended_get_projection_stmt(sqlite3_stmt *s
        int i=0;
        int stmt_count = 0;
 
-       for(i=0;i<projection_count;i++)
-       {
+       for(i=0;i<projection_count;i++) {
                _cal_db_instance_normal_extended_get_property_stmt(stmt,projection[i],&stmt_count,record);
        }
 }
index c3ed729..149f90a 100644 (file)
@@ -78,37 +78,31 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
        que = (cal_query_s *)query;
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query,
                                &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
-                       ERR("filter create fail");
+               if (CALENDAR_ERROR_NONE != ret) {
+                       ERR("filter create Fail");
                        return ret;
                }
        }
 
        // make projection
-       if (0 < que->projection_count)
-       {
+       if (0 < que->projection_count) {
                ret = cal_db_query_create_projection(query, &projection);
        }
-       else
-       {
+       else {
                _cal_db_search_make_projection(query, &projection);
        }
 
        char *query_str = NULL;
-       if (que->distinct == true)
-       {
+       if (que->distinct == true) {
                cal_db_append_string(&query_str, "SELECT DISTINCT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
                cal_db_append_string(&query_str, table_name);
        }
-       else
-       {
+       else {
                cal_db_append_string(&query_str, "SELECT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
@@ -118,8 +112,7 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -128,8 +121,7 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
        // ORDER
        char *order = NULL;
        ret = cal_db_query_create_order(query, condition, &order);
-       if (order)
-       {
+       if (order) {
                cal_db_append_string(&query_str, order);
                CAL_FREE(order);
        }
@@ -137,13 +129,11 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
 
        // limit, offset
        char buf[32] = {0};
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (0 < offset)
-               {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -165,21 +155,17 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
        DBG("%s",query_str);
 
        // bind text
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_length(bind_text);
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
 
        //
        ret = calendar_list_create(out_list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -189,8 +175,7 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
                return ret;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(que->view_uri,&record);
@@ -198,8 +183,7 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
                        calendar_list_destroy(*out_list, true);
                        *out_list = NULL;
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -207,13 +191,11 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
                        CAL_FREE(query_str);
                        return ret;
                }
-               if (0 < que->projection_count)
-               {
+               if (0 < que->projection_count) {
                        _cal_db_search_get_projection_stmt(stmt,que->projection,que->projection_count,
                                        record);
                }
-               else
-               {
+               else {
                        _cal_db_search_get_stmt(stmt, query,record);
                }
 
@@ -223,8 +205,7 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
                        *out_list = NULL;
                        calendar_record_destroy(record, true);
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -234,8 +215,7 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
                }
        }
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -257,45 +237,37 @@ static int _cal_db_search_get_count_with_query(calendar_query_h query, int *out_
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
                projection = SAFE_STRDUP("id");
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
                projection = SAFE_STRDUP("id");
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
                projection = SAFE_STRDUP("id");
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
                projection = SAFE_STRDUP("event_id");
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
                projection = SAFE_STRDUP("event_id");
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
-                       ERR("filter create fail");
+                       ERR("filter create Fail");
                        CAL_FREE(projection);
                        return ret;
                }
@@ -304,15 +276,13 @@ static int _cal_db_search_get_count_with_query(calendar_query_h query, int *out_
        char *query_str = NULL;
 
        // query - select from
-       if (que->distinct == true)
-       {
+       if (que->distinct == true) {
                cal_db_append_string(&query_str, "SELECT count(DISTINCT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, ") FROM");
                cal_db_append_string(&query_str, table_name);
        }
-       else
-       {
+       else {
                cal_db_append_string(&query_str, "SELECT count(*) FROM");
                cal_db_append_string(&query_str, table_name);
        }
@@ -320,8 +290,7 @@ static int _cal_db_search_get_count_with_query(calendar_query_h query, int *out_
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -330,11 +299,9 @@ static int _cal_db_search_get_count_with_query(calendar_query_h query, int *out_
 
        // query
        ret = cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Failed");
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -345,8 +312,7 @@ static int _cal_db_search_get_count_with_query(calendar_query_h query, int *out_
        DBG("count(%d) str[%s]", count, query_str);
 
        if (out_count) *out_count = count;
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -365,12 +331,10 @@ static void _cal_db_search_get_stmt(sqlite3_stmt *stmt,calendar_query_h query,
 
        query_s = (cal_query_s *)query;
 
-       for (i=0;i<query_s->property_count;i++)
-       {
+       for (i=0;i<query_s->property_count;i++) {
                properties = &(query_s->properties[i]);
 
-               if (CAL_PROPERTY_CHECK_FLAGS(properties->property_id, CAL_PROPERTY_FLAGS_FILTER) == true)
-               {
+               if (CAL_PROPERTY_CHECK_FLAGS(properties->property_id, CAL_PROPERTY_FLAGS_FILTER) == true) {
                        break;
                }
 
@@ -388,32 +352,26 @@ static void _cal_db_search_get_property_stmt(sqlite3_stmt *stmt,
        double d_tmp = 0;
        long long int lli_tmp = 0;
 
-       if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_INT) == true)
-       {
+       if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_INT) == true) {
                int_tmp = sqlite3_column_int(stmt, *stmt_count);
                cal_record_set_int(record,property,int_tmp);
        }
-       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_STR) == true)
-       {
+       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_STR) == true) {
                temp = sqlite3_column_text(stmt, *stmt_count);
                cal_record_set_str(record,property,(const char*)temp);
        }
-       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
-       {
+       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
                d_tmp = sqlite3_column_double(stmt,*stmt_count);
                cal_record_set_double(record,property,d_tmp);
        }
-       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_LLI) == true)
-       {
+       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_LLI) == true) {
                lli_tmp = sqlite3_column_int64(stmt, *stmt_count);
                cal_record_set_lli(record,property,lli_tmp);
        }
-       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
-       {
+       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
                calendar_time_s caltime_tmp;
                caltime_tmp.type = sqlite3_column_int(stmt,*stmt_count);
-               switch (caltime_tmp.type)
-               {
+               switch (caltime_tmp.type) {
                case CALENDAR_TIME_UTIME:
                        *stmt_count = *stmt_count+1;
                        caltime_tmp.time.utime = sqlite3_column_int64(stmt,*stmt_count);
@@ -435,8 +393,7 @@ static void _cal_db_search_get_property_stmt(sqlite3_stmt *stmt,
                ret = cal_record_set_caltime(record,property,caltime_tmp);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "Failed to cal_record_set_caltime()");
        }
-       else
-       {
+       else {
                sqlite3_column_int(stmt, *stmt_count);
        }
 
@@ -449,8 +406,7 @@ static void _cal_db_search_get_projection_stmt(sqlite3_stmt *stmt,
        int i=0;
        int stmt_count = 0;
 
-       for(i=0;i<projection_count;i++)
-       {
+       for(i=0;i<projection_count;i++) {
                _cal_db_search_get_property_stmt(stmt,projection[i],&stmt_count,record);
        }
 }
@@ -472,27 +428,22 @@ static int _cal_db_search_make_projection(calendar_query_h query, char **project
        if (field_name)
                len += snprintf(out_projection+len, sizeof(out_projection)-len, "%s", field_name);
 
-       if (sizeof(out_projection) <= len)
-       {
+       if (sizeof(out_projection) <= len) {
                ERR("buf len max");
                return CALENDAR_ERROR_SYSTEM;
        }
 
-       for (i=1;i<query_s->property_count;i++)
-       {
+       for (i=1;i<query_s->property_count;i++) {
                properties = &(query_s->properties[i]);
                field_name = properties->fields;
 
-               if (CAL_PROPERTY_CHECK_FLAGS(properties->property_id, CAL_PROPERTY_FLAGS_FILTER) == true)
-               {
+               if (CAL_PROPERTY_CHECK_FLAGS(properties->property_id, CAL_PROPERTY_FLAGS_FILTER) == true) {
                        break;
                }
 
-               if (field_name)
-               {
+               if (field_name) {
                        len += snprintf(out_projection+len, sizeof(out_projection)-len, ", %s", field_name);
-                       if (sizeof(out_projection) <= len)
-                       {
+                       if (sizeof(out_projection) <= len) {
                                ERR("buf len max");
                                return CALENDAR_ERROR_SYSTEM;
                        }
index 9a8fea9..cdd95f1 100644 (file)
@@ -92,24 +92,13 @@ static int _cal_db_timezone_insert_record(calendar_record_h record, int* id)
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "cal_db_get_record() Fail(%d)", ret);
        calendar_record_destroy(record_calendar, true);
 
-       // start >>>>> check if we already have
-       /*
-               if (timezone->standard_name == NULL || strlen(timezone->standard_name) == 0)
-               {
-               ERR("No timezone starndard name");
-               return CALENDAR_ERROR_INVALID_PARAMETER;
-               }
-        */
-       if (timezone->standard_name)
-       {
-               snprintf(query, sizeof(query), "SELECT count(*), id FROM %s "
-                               "WHERE standard_name = ? ",
+       if (timezone->standard_name) {
+               snprintf(query, sizeof(query), "SELECT count(*), id FROM %s WHERE standard_name=? ",
                                CAL_TABLE_TIMEZONE);
 
                stmt = cal_db_util_query_prepare(query);
-               if (NULL == stmt)
-               {
-                       ERR("cal_db_util_query_prepare() failed");
+               if (NULL == stmt) {
+                       ERR("cal_db_util_query_prepare() Fail");
                        return CALENDAR_ERROR_DB_FAILED;
                }
                cal_db_util_stmt_bind_text(stmt, 1, timezone->standard_name);
@@ -117,7 +106,7 @@ static int _cal_db_timezone_insert_record(calendar_record_h record, int* id)
                dbret = cal_db_util_stmt_step(stmt);
                if (CAL_DB_ROW != dbret)
                {
-                       ERR("cal_db_util_stmt_step() failed");
+                       ERR("cal_db_util_stmt_step() Fail");
                        sqlite3_finalize(stmt);
                        switch (dbret)
                        {
@@ -133,8 +122,7 @@ static int _cal_db_timezone_insert_record(calendar_record_h record, int* id)
                int timezone_id = sqlite3_column_int(stmt, index++);
                sqlite3_finalize(stmt);
 
-               if (0 < count)
-               {
+               if (0 < count) {
                        DBG("Already exist which tzid name[%s] id(%d)", timezone->standard_name, timezone_id);
                        *id = timezone_id;
                        return CALENDAR_ERROR_NONE;
@@ -191,8 +179,7 @@ static int _cal_db_timezone_insert_record(calendar_record_h record, int* id)
        sqlite3_finalize(stmt);
 
        //cal_record_set_int(record, _calendar_timezone.id,index);
-       if (id)
-       {
+       if (id) {
                *id = index;
        }
 
@@ -207,9 +194,8 @@ static int _cal_db_timezone_get_record(int id, calendar_record_h* out_record)
        int ret = 0;
 
        ret = calendar_record_create(_calendar_timezone._uri ,out_record);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("record create fail");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("record create Fail");
                return CALENDAR_ERROR_OUT_OF_MEMORY;
        }
 
@@ -229,7 +215,7 @@ static int _cal_db_timezone_get_record(int id, calendar_record_h* out_record)
        dbret = cal_db_util_stmt_step(stmt);
        if (CAL_DB_ROW != dbret)
        {
-               ERR("cal_db_util_stmt_step() failed(%d)", dbret);
+               ERR("cal_db_util_stmt_step() Fail(%d)", dbret);
                sqlite3_finalize(stmt);
                calendar_record_destroy(*out_record, true);
                *out_record = NULL;
@@ -261,8 +247,7 @@ static int _cal_db_timezone_update_record(calendar_record_h record)
 
        RETV_IF(NULL == timezone_info, CALENDAR_ERROR_INVALID_PARAMETER);
 
-       if (timezone_info->common.properties_flags != NULL)
-       {
+       if (timezone_info->common.properties_flags) {
                return _cal_db_timezone_update_projection(record);
        }
 
@@ -356,8 +341,7 @@ static int _cal_db_timezone_replace_record(calendar_record_h record, int id)
        RETV_IF(NULL == timezone_info, CALENDAR_ERROR_INVALID_PARAMETER);
        timezone_info->index = id;
 
-       if (timezone_info->common.properties_flags != NULL)
-       {
+       if (timezone_info->common.properties_flags) {
                return _cal_db_timezone_update_projection(record);
        }
 
@@ -431,12 +415,10 @@ static int _cal_db_timezone_get_all_records(int offset, int limit, calendar_list
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (0 < offset)
-       {
+       if (0 < offset) {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
        }
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
        }
        snprintf(query, sizeof(query), "SELECT * FROM %s where "
@@ -457,8 +439,7 @@ static int _cal_db_timezone_get_all_records(int offset, int limit, calendar_list
                return CALENDAR_ERROR_DB_FAILED;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(_calendar_timezone._uri,&record);
@@ -499,12 +480,10 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
        que = (cal_query_s *)query;
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
-                       ERR("filter create fail");
+               if (CALENDAR_ERROR_NONE != ret) {
+                       ERR("filter create Fail");
                        return ret;
                }
        }
@@ -513,32 +492,26 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
        ret = cal_db_query_create_projection(query, &projection);
 
        // query - projection
-       if (projection)
-       {
+       if (projection) {
                cal_db_append_string(&query_str, "SELECT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
                cal_db_append_string(&query_str, CAL_TABLE_TIMEZONE);
                CAL_FREE(projection);
-       }
-       else
-       {
+       } else {
                cal_db_append_string(&query_str, "SELECT * FROM");
                cal_db_append_string(&query_str, CAL_TABLE_TIMEZONE);
        }
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE");
                cal_db_append_string(&query_str, condition);
                CAL_FREE(condition);
                cal_db_append_string(&query_str, "AND calendar_id IN (select id from");
                cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
                cal_db_append_string(&query_str, "where deleted = 0)");
-       }
-       else
-       {
+       } else {
                cal_db_append_string(&query_str, "WHERE calendar_id IN (select id from");
                cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
                cal_db_append_string(&query_str, "where deleted = 0)");
@@ -546,19 +519,16 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
 
        // ORDER
        ret = cal_db_query_create_order(query, condition, &order);
-       if (order)
-       {
+       if (order) {
                cal_db_append_string(&query_str, order);
                CAL_FREE(order);
        }
 
        char buf[32] = {0};
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
-               if (0 < offset)
-               {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -579,20 +549,16 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
        }
 
        // bind text
-       if (bind_text)
-       {
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+       if (bind_text) {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
 
        //
        ret = calendar_list_create(out_list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -602,8 +568,7 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
                return ret;
        }
 
-       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-       {
+       while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                calendar_record_h record;
                // stmt -> record
                ret = calendar_record_create(_calendar_timezone._uri,&record);
@@ -611,8 +576,7 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
                        calendar_list_destroy(*out_list, true);
                        *out_list = NULL;
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -620,17 +584,14 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
                        sqlite3_finalize(stmt);
                        return ret;
                }
-               if (0 < que->projection_count)
-               {
+               if (0 < que->projection_count) {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
                        _cal_db_timezone_get_projection_stmt(stmt,
                                        que->projection, que->projection_count,
                                        record);
-               }
-               else
-               {
+               } else {
                        _cal_db_timezone_get_stmt(stmt,record);
                }
 
@@ -640,8 +601,7 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
                        *out_list = NULL;
                        calendar_record_destroy(record, true);
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -651,8 +611,7 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
                }
        }
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -670,27 +629,23 @@ static int _cal_db_timezone_insert_records(const calendar_list_h list, int** ids
        int *id = NULL;
 
        ret = calendar_list_get_count(list, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list get error");
                return ret;
        }
 
        id = calloc(1, sizeof(int)*count);
 
-       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                CAL_FREE(id);
                return ret;
        }
-       do
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       do {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_timezone_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                CAL_FREE(id);
@@ -698,14 +653,11 @@ static int _cal_db_timezone_insert_records(const calendar_list_h list, int** ids
                        }
                }
                i++;
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
-       if (ids)
-       {
+       if (ids) {
                *ids = id;
-       }
-       else
-       {
+       } else {
                CAL_FREE(id);
        }
 
@@ -718,21 +670,18 @@ static int _cal_db_timezone_update_records(const calendar_list_h list)
        int ret = 0;
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                return ret;
        }
-       do
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       do {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_timezone_update_record(record) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                return CALENDAR_ERROR_DB_FAILED;
                        }
                }
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
        return CALENDAR_ERROR_NONE;
 }
@@ -741,11 +690,9 @@ static int _cal_db_timezone_delete_records(int ids[], int count)
 {
        int i = 0;
 
-       for(i = 0; i < count; i++)
-       {
-               if (_cal_db_timezone_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
-               {
-                       ERR("delete failed");
+       for(i = 0; i < count; i++) {
+               if (_cal_db_timezone_delete_record(ids[i]) != CALENDAR_ERROR_NONE) {
+                       ERR("delete Fail");
                        return CALENDAR_ERROR_DB_FAILED;
                }
        }
@@ -761,24 +708,19 @@ static int _cal_db_timezone_replace_records(const calendar_list_h list, int ids[
        RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                return ret;
        }
 
-       for (i = 0; i < count; i++)
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
-                       if (_cal_db_timezone_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
-                       {
+       for (i = 0; i < count; i++) {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
+                       if (_cal_db_timezone_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                return CALENDAR_ERROR_DB_FAILED;
                        }
                }
-               if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
-               {
+               if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list)) {
                        break;
                }
        }
@@ -800,9 +742,8 @@ static int _cal_db_timezone_get_count(int *out_count)
                        CAL_TABLE_CALENDAR);
 
        ret = cal_db_util_query_get_first_int_result(query, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                return ret;
        }
        DBG("%s=%d",query,count);
@@ -823,24 +764,20 @@ static int _cal_db_timezone_get_count_with_query(calendar_query_h query, int *ou
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TIMEZONE))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TIMEZONE)) {
                table_name = SAFE_STRDUP(CAL_TABLE_TIMEZONE);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
-                       ERR("filter create fail");
+                       ERR("filter create Fail");
                        return ret;
                }
        }
@@ -851,17 +788,14 @@ static int _cal_db_timezone_get_count_with_query(calendar_query_h query, int *ou
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, "AND calendar_id IN (select id from");
                cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
                cal_db_append_string(&query_str, "where deleted = 0)");
                CAL_FREE(condition);
-       }
-       else
-       {
+       } else {
                cal_db_append_string(&query_str, "WHERE calendar_id IN (select id from");
                cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
                cal_db_append_string(&query_str, "where deleted = 0)");
@@ -869,11 +803,9 @@ static int _cal_db_timezone_get_count_with_query(calendar_query_h query, int *ou
 
        // query
        ret = cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -884,8 +816,7 @@ static int _cal_db_timezone_get_count_with_query(calendar_query_h query, int *ou
 
        *out_count = count;
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -929,8 +860,7 @@ static void _cal_db_timezone_get_property_stmt(sqlite3_stmt *stmt,
        cal_timezone_s* timezone =  (cal_timezone_s*)(record);
        const unsigned char *temp;
 
-       switch (property)
-       {
+       switch (property) {
        case CAL_PROPERTY_TIMEZONE_ID:
                timezone->index = sqlite3_column_int(stmt, stmt_count);
                break;
@@ -992,8 +922,7 @@ static void _cal_db_timezone_get_projection_stmt(sqlite3_stmt *stmt,
 {
        int i=0;
 
-       for(i=0;i<projection_count;i++)
-       {
+       for(i=0;i<projection_count;i++) {
                _cal_db_timezone_get_property_stmt(stmt,projection[i],i,record);
        }
 }
@@ -1030,8 +959,7 @@ static int _cal_db_timezone_update_projection(calendar_record_h record)
        if (bind_text)
        {
                int i = 0;
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
index 320eabe..be77117 100644 (file)
@@ -100,9 +100,8 @@ static int _cal_db_todo_insert_record(calendar_record_h record, int* id)
        RETV_IF(false == _cal_db_todo_check_calendar_book_type(record), CALENDAR_ERROR_INVALID_PARAMETER);
 
        // access control
-       if (cal_access_control_have_write_permission(todo->calendar_id) == false)
-       {
-               ERR("cal_access_control_have_write_permission() failed");
+       if (cal_access_control_have_write_permission(todo->calendar_id) == false) {
+               ERR("cal_access_control_have_write_permission() Fail");
                return CALENDAR_ERROR_PERMISSION_DENIED;
        }
 
@@ -212,8 +211,7 @@ static int _cal_db_todo_insert_record(calendar_record_h record, int* id)
                cal_db_util_stmt_bind_text(stmt, count, todo->uid);
        count++;
 
-       if (CALENDAR_TIME_LOCALTIME == todo->start.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == todo->start.type) {
                snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                todo->start.time.date.year,
                                todo->start.time.date.month,
@@ -229,8 +227,7 @@ static int _cal_db_todo_insert_record(calendar_record_h record, int* id)
                cal_db_util_stmt_bind_text(stmt, count, todo->start_tzid);
        count++;
 
-       if (CALENDAR_TIME_LOCALTIME == todo->due.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == todo->due.type) {
                snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                todo->due.time.date.year,
                                todo->due.time.date.month,
@@ -292,20 +289,19 @@ static int _cal_db_todo_insert_record(calendar_record_h record, int* id)
 
        if (todo->alarm_list && 0 < todo->alarm_list->count) {
                ret = cal_db_alarm_insert_records(todo->alarm_list, index);
-               WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_db_alarm_insert_records() failed(%x)", ret);
+               WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_db_alarm_insert_records() Fail(%x)", ret);
        }
 
        if (todo->attendee_list && 0 < todo->attendee_list->count) {
                ret = cal_db_attendee_insert_records(todo->attendee_list, index);
-               WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_db_attendee_insert_records() failed(%x)", ret);
+               WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_db_attendee_insert_records() Fail(%x)", ret);
        }
 
        if (todo->extended_list && 0 < todo->extended_list->count) {
                DBG("insert extended");
                ret = cal_db_extended_insert_records(todo->extended_list, index, CALENDAR_RECORD_TYPE_TODO);
                WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_db_extended_insert_records() Fail(%x)", ret);
-       }
-       else {
+       } else {
                DBG("No extended");
        }
 
@@ -331,8 +327,7 @@ static int _cal_db_todo_get_record(int id, calendar_record_h* out_record)
        int ret = 0;
 
        rc = calendar_record_create(_calendar_todo._uri ,out_record);
-       if (rc != CALENDAR_ERROR_NONE)
-       {
+       if (rc != CALENDAR_ERROR_NONE) {
                ERR("calendar_record_create(%d)", rc);
                return CALENDAR_ERROR_OUT_OF_MEMORY;
        }
@@ -377,25 +372,21 @@ static int _cal_db_todo_get_record(int id, calendar_record_h* out_record)
        stmt = NULL;
 
        //check
-       ret = cal_db_get_record(_calendar_book._uri,
-                       todo->calendar_id, &record_calendar);
-       if (CALENDAR_ERROR_NONE == ret)
-       {
+       ret = cal_db_get_record(_calendar_book._uri, todo->calendar_id, &record_calendar);
+       if (CALENDAR_ERROR_NONE == ret) {
                ret = calendar_record_get_int(record_calendar,
                                _calendar_book.sync_event, (int *)&sync_event_type);
                calendar_record_destroy(record_calendar, true);
        }
        if (todo->is_deleted == 1
                        && sync_event_type != CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN
-               )
-       {
+               ) {
                calendar_record_destroy(*out_record, true);
                *out_record = NULL;
                return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
        }
 
-       if (cal_db_rrule_get_rrule(todo->index, &rrule) == CALENDAR_ERROR_NONE)
-       {
+       if (cal_db_rrule_get_rrule(todo->index, &rrule) == CALENDAR_ERROR_NONE) {
                cal_db_rrule_set_rrule_to_todo(rrule, *out_record);
                CAL_FREE(rrule);
        }
@@ -427,16 +418,14 @@ static int _cal_db_todo_update_record(calendar_record_h record)
        RETV_IF(NULL == todo, CALENDAR_ERROR_INVALID_PARAMETER);
 
        // access control
-       if (cal_access_control_have_write_permission(todo->calendar_id) == false)
-       {
-               ERR("cal_access_control_have_write_permission() failed");
+       if (cal_access_control_have_write_permission(todo->calendar_id) == false) {
+               ERR("cal_access_control_have_write_permission() Fail");
                return CALENDAR_ERROR_PERMISSION_DENIED;
        }
 
        //if (CAL_SYNC_STATUS_UPDATED != todo->sync_status)
        //  todo->sync_status = CAL_SYNC_STATUS_UPDATED;
-       if (todo->common.properties_flags != NULL)
-       {
+       if (todo->common.properties_flags != NULL) {
                return _cal_db_todo_update_dirty(record);
        }
 
@@ -538,8 +527,7 @@ static int _cal_db_todo_update_record(calendar_record_h record)
                cal_db_util_stmt_bind_text(stmt, count, todo->uid);
        count++;
 
-       if (CALENDAR_TIME_LOCALTIME == todo->start.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == todo->start.type) {
                snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                todo->start.time.date.year,
                                todo->start.time.date.month,
@@ -555,8 +543,7 @@ static int _cal_db_todo_update_record(calendar_record_h record)
                cal_db_util_stmt_bind_text(stmt, count, todo->start_tzid);
        count++;
 
-       if (CALENDAR_TIME_LOCALTIME == todo->due.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == todo->due.type) {
                snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                todo->due.time.date.year,
                                todo->due.time.date.month,
@@ -649,31 +636,27 @@ static int _cal_db_todo_delete_record(int id)
        RETVM_IF(id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "id(%d) < 0", id);
 
        ret = _cal_db_todo_get_deleted_data(id, &calendar_book_id, &created_ver);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               DBG("_cal_db_event_get_deleted_data() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               DBG("_cal_db_event_get_deleted_data() Fail");
                return ret;
        }
 
        //access control
-       if (cal_access_control_have_write_permission(calendar_book_id) == false)
-       {
-               ERR("fail");
+       if (cal_access_control_have_write_permission(calendar_book_id) == false) {
+               ERR("cal_access_control_have_write_permission() Fail");
                return CALENDAR_ERROR_PERMISSION_DENIED;
        }
 
        snprintf(query, sizeof(query), "SELECT sync_event FROM %s WHERE id = %d ",
                        CAL_TABLE_CALENDAR, calendar_book_id);
        ret = cal_db_util_query_get_first_int_result(query, NULL, (int *)&sync_event_type);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                return ret;
        }
        DBG("sync_event_type(%d)", sync_event_type);
 
-       if (sync_event_type == CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN)
-       {
+       if (sync_event_type == CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN) {
                DBG("set is_delete");
                snprintf(query, sizeof(query),
                                "UPDATE %s "
@@ -688,7 +671,7 @@ static int _cal_db_todo_delete_record(int id)
                dbret = cal_db_util_query_exec(query);
                if (dbret != CAL_DB_OK)
                {
-                       ERR("cal_db_util_query_exec() failed (%d)", dbret);
+                       ERR("cal_db_util_query_exec() Fail (%d)", dbret);
                        switch (dbret)
                        {
                        case CAL_DB_ERROR_NO_SPACE:
@@ -700,8 +683,7 @@ static int _cal_db_todo_delete_record(int id)
 
                DBG("attendee, alarm and rrule will be deleted by trigger after sync clean");
        }
-       else
-       {
+       else {
                cal_db_util_get_next_ver();
 
                DBG("delete event");
@@ -748,16 +730,14 @@ static int _cal_db_todo_replace_record(calendar_record_h record, int id)
        todo->index = id;
 
        // access control
-       if (cal_access_control_have_write_permission(todo->calendar_id) == false)
-       {
-               ERR("cal_access_control_have_write_permission() failed");
+       if (cal_access_control_have_write_permission(todo->calendar_id) == false) {
+               ERR("cal_access_control_have_write_permission() Fail");
                return CALENDAR_ERROR_PERMISSION_DENIED;
        }
 
        //if (CAL_SYNC_STATUS_UPDATED != todo->sync_status)
        //  todo->sync_status = CAL_SYNC_STATUS_UPDATED;
-       if (todo->common.properties_flags != NULL)
-       {
+       if (todo->common.properties_flags) {
                return _cal_db_todo_update_dirty(record);
        }
        int is_allday = 0;
@@ -858,8 +838,7 @@ static int _cal_db_todo_replace_record(calendar_record_h record, int id)
                cal_db_util_stmt_bind_text(stmt, count, todo->uid);
        count++;
 
-       if (CALENDAR_TIME_LOCALTIME == todo->start.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == todo->start.type) {
                snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                todo->start.time.date.year,
                                todo->start.time.date.month,
@@ -875,8 +854,7 @@ static int _cal_db_todo_replace_record(calendar_record_h record, int id)
                cal_db_util_stmt_bind_text(stmt, count, todo->start_tzid);
        count++;
 
-       if (CALENDAR_TIME_LOCALTIME == todo->due.type)
-       {
+       if (CALENDAR_TIME_LOCALTIME == todo->due.type) {
                snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
                                todo->due.time.date.year,
                                todo->due.time.date.month,
@@ -937,12 +915,12 @@ static int _cal_db_todo_replace_record(calendar_record_h record, int id)
 
        if (todo->alarm_list && 0 < todo->alarm_list->count) {
                ret = cal_db_alarm_insert_records(todo->alarm_list, id);
-               WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_db_alarm_insert_records() failed(%x)", ret);
+               WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_db_alarm_insert_records() Fail(%x)", ret);
        }
 
        if (todo->attendee_list && 0 < todo->attendee_list->count) {
                ret = cal_db_attendee_insert_records(todo->attendee_list, id);
-               WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_db_attendee_insert_records() failed(%x)", ret);
+               WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_db_attendee_insert_records() Fail(%x)", ret);
        }
 
        if (todo->extended_list && 0 < todo->extended_list->count) {
@@ -968,12 +946,10 @@ static int _cal_db_todo_get_all_records(int offset, int limit, calendar_list_h*
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (0 < offset)
-       {
+       if (0 < offset) {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
        }
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
        }
 
@@ -1013,17 +989,13 @@ static int _cal_db_todo_get_all_records(int offset, int limit, calendar_list_h*
                int record_id = 0;
                cal_todo_s* ptodo = (cal_todo_s*) record;
                calendar_record_get_int(record, _calendar_todo.id, &record_id);
-               if (calendar_record_get_int(record, _calendar_todo.has_attendee,&has_attendee) == CALENDAR_ERROR_NONE)
-               {
-                       if (has_attendee == 1)
-                       {
+               if (calendar_record_get_int(record, _calendar_todo.has_attendee,&has_attendee) == CALENDAR_ERROR_NONE) {
+                       if (has_attendee == 1) {
                                cal_db_attendee_get_records(record_id, ptodo->attendee_list);
                        }
                }
-               if (calendar_record_get_int(record, _calendar_todo.has_alarm,&has_alarm) == CALENDAR_ERROR_NONE)
-               {
-                       if (has_alarm == 1)
-                       {
+               if (calendar_record_get_int(record, _calendar_todo.has_alarm,&has_alarm) == CALENDAR_ERROR_NONE) {
+                       if (has_alarm == 1) {
                                cal_db_alarm_get_records(record_id, ptodo->alarm_list);
                        }
                }
@@ -1060,29 +1032,24 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
                //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
-                       ERR("filter create fail");
+                       ERR("filter create Fail");
                        return ret;
                }
        }
@@ -1093,24 +1060,20 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
        char *query_str = NULL;
 
        // query - projection
-       if (projection)
-       {
+       if (projection) {
                cal_db_append_string(&query_str, "SELECT");
                cal_db_append_string(&query_str, projection);
                cal_db_append_string(&query_str, "FROM");
                cal_db_append_string(&query_str, table_name);
                CAL_FREE(projection);
-       }
-       else
-       {
+       } else {
                cal_db_append_string(&query_str, "SELECT * FROM");
                cal_db_append_string(&query_str, table_name);
        }
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str, "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -1119,8 +1082,7 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
        // ORDER
        char *order = NULL;
        ret = cal_db_query_create_order(query, condition, &order);
-       if (order)
-       {
+       if (order) {
                cal_db_append_string(&query_str, order);
                CAL_FREE(order);
        }
@@ -1128,13 +1090,11 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
 
        // limit, offset
        char buf[32] = {0};
-       if (0 < limit)
-       {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (0 < offset)
-               {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -1156,21 +1116,17 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
        DBG("%s",query_str);
 
        // bind text
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_length(bind_text);
-               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
-               {
+               for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
                        cal_db_util_stmt_bind_text(stmt, i, cursor->data);
                }
        }
 
        //
        ret = calendar_list_create(out_list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -1191,8 +1147,7 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
                        calendar_list_destroy(*out_list, true);
                        *out_list = NULL;
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -1200,40 +1155,33 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
                        CAL_FREE(query_str);
                        return ret;
                }
-               if (0 < que->projection_count)
-               {
+               if (0 < que->projection_count) {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
                        _cal_db_todo_get_projection_stmt(stmt,
                                        que->projection, que->projection_count,
                                        record);
-               }
-               else
-               {
+               } else {
                        cal_todo_s *todo = NULL;
                        _cal_db_todo_get_stmt(stmt,true,record, &extended);
                        todo = (cal_todo_s*)(record);
-                       if (todo)
-                       {
+                       if (todo) {
                                attendee = todo->has_attendee;
                                alarm = todo->has_alarm;
                        }
                }
 
                // child
-               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_CALENDAR_ALARM) == true && alarm ==1)
-               {
+               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_CALENDAR_ALARM) == true && alarm ==1) {
                        cal_todo_s* todo = (cal_todo_s*) record;
                        cal_db_alarm_get_records(todo->index, todo->alarm_list);
                }
-               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_CALENDAR_ATTENDEE) == true && attendee==1)
-               {
+               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_CALENDAR_ATTENDEE) == true && attendee==1) {
                        cal_todo_s* todo = (cal_todo_s*) record;
                        cal_db_attendee_get_records(todo->index, todo->attendee_list);
                }
-               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_EXTENDED) == true && extended == 1)
-               {
+               if (cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_EXTENDED) == true && extended == 1) {
                        cal_todo_s* todo = (cal_todo_s*) record;
                        cal_db_extended_get_records(todo->index, CALENDAR_RECORD_TYPE_TODO, todo->extended_list);
                }
@@ -1244,8 +1192,7 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
                        *out_list = NULL;
                        calendar_record_destroy(record, true);
 
-                       if (bind_text)
-                       {
+                       if (bind_text) {
                                g_slist_free_full(bind_text, free);
                                bind_text = NULL;
                        }
@@ -1255,8 +1202,7 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
                }
        }
 
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -1276,27 +1222,23 @@ static int _cal_db_todo_insert_records(const calendar_list_h list, int** ids)
        int *id = NULL;
 
        ret = calendar_list_get_count(list, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list get error");
                return ret;
        }
 
        id = calloc(1, sizeof(int)*count);
 
-       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+       RETVM_IF(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                CAL_FREE(id);
                return ret;
        }
-       do
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       do {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_todo_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                CAL_FREE(id);
@@ -1304,14 +1246,11 @@ static int _cal_db_todo_insert_records(const calendar_list_h list, int** ids)
                        }
                }
                i++;
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
-       if (ids)
-       {
+       if (ids) {
                *ids = id;
-       }
-       else
-       {
+       } else {
                CAL_FREE(id);
        }
 
@@ -1324,21 +1263,18 @@ static int _cal_db_todo_update_records(const calendar_list_h list)
        int ret = 0;
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                return ret;
        }
-       do
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       do {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_todo_update_record(record) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                return CALENDAR_ERROR_DB_FAILED;
                        }
                }
-       } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+       } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
 
        return CALENDAR_ERROR_NONE;
 }
@@ -1346,11 +1282,9 @@ static int _cal_db_todo_update_records(const calendar_list_h list)
 static int _cal_db_todo_delete_records(int ids[], int count)
 {
        int i=0;
-       for(i=0;i<count;i++)
-       {
-               if (_cal_db_todo_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
-               {
-                       ERR("delete failed");
+       for(i=0;i<count;i++) {
+               if (_cal_db_todo_delete_record(ids[i]) != CALENDAR_ERROR_NONE) {
+                       ERR("delete Fail");
                        return CALENDAR_ERROR_DB_FAILED;
                }
        }
@@ -1368,9 +1302,8 @@ static int _cal_db_todo_get_count(int *out_count)
        int ret = 0;
        int count = 0;
        ret = cal_db_util_query_get_first_int_result(query_str, NULL, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
                CAL_FREE(query_str);
                return ret;
        }
@@ -1387,30 +1320,25 @@ static int _cal_db_todo_replace_records(const calendar_list_h list, int ids[], i
        int i = 0;
        int ret = 0;
 
-       if (NULL == list)
-       {
+       if (NULL == list) {
                ERR("Invalid argument: list is NULL");
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        ret = calendar_list_first(list);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
+       if (CALENDAR_ERROR_NONE != ret) {
                ERR("list first error");
                return ret;
        }
 
-       for (i = 0; i < count; i++)
-       {
-               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
-               {
+       for (i = 0; i < count; i++) {
+               if (calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
                        if (_cal_db_todo_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE) {
                                ERR("db insert error");
                                return CALENDAR_ERROR_DB_FAILED;
                        }
                }
-               if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
-               {
+               if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list)) {
                        break;
                }
        }
@@ -1430,28 +1358,23 @@ static int _cal_db_todo_get_count_with_query(calendar_query_h query, int *out_co
 
        que = (cal_query_s *)query;
 
-       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO))
-       {
+       if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO);
        }
-       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
-       {
+       else if (CAL_STRING_EQUAL == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR)) {
                table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
        }
-       else
-       {
+       else {
                ERR("uri(%s) not support get records with query",que->view_uri);
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        // make filter
-       if (que->filter)
-       {
+       if (que->filter) {
                ret = cal_db_query_create_condition(query, &condition, &bind_text);
-               if (CALENDAR_ERROR_NONE != ret)
-               {
+               if (CALENDAR_ERROR_NONE != ret) {
                        CAL_FREE(table_name);
-                       ERR("filter create fail");
+                       ERR("filter create Fail");
                        return ret;
                }
        }
@@ -1463,8 +1386,7 @@ static int _cal_db_todo_get_count_with_query(calendar_query_h query, int *out_co
        CAL_FREE(table_name);
 
        // query - condition
-       if (condition)
-       {
+       if (condition) {
                cal_db_append_string(&query_str,  "WHERE (");
                cal_db_append_string(&query_str, condition);
                cal_db_append_string(&query_str, ")");
@@ -1473,11 +1395,9 @@ static int _cal_db_todo_get_count_with_query(calendar_query_h query, int *out_co
 
        // query
        ret = cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("cal_db_util_query_get_first_int_result() failed");
-               if (bind_text)
-               {
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("cal_db_util_query_get_first_int_result() Fail");
+               if (bind_text) {
                        g_slist_free_full(bind_text, free);
                        bind_text = NULL;
                }
@@ -1487,8 +1407,7 @@ static int _cal_db_todo_get_count_with_query(calendar_query_h query, int *out_co
        DBG("count(%d) str[%s]", count, query_str);
 
        if (out_count) *out_count = count;
-       if (bind_text)
-       {
+       if (bind_text) {
                g_slist_free_full(bind_text, free);
                bind_text = NULL;
        }
@@ -1560,13 +1479,10 @@ static void _cal_db_todo_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar
 
        todo->start.type = sqlite3_column_int(stmt,count++);
 
-       if (todo->start.type == CALENDAR_TIME_UTIME)
-       {
+       if (todo->start.type == CALENDAR_TIME_UTIME) {
                todo->start.time.utime = sqlite3_column_int64(stmt,count++);
                count++; // dtstart_datetime
-       }
-       else
-       {
+       } else {
                count++; // dtstart_utime
                temp = sqlite3_column_text(stmt, count++);
                if (temp) {
@@ -1580,13 +1496,10 @@ static void _cal_db_todo_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar
        temp = sqlite3_column_text(stmt, count++);
        todo->start_tzid = SAFE_STRDUP(temp);
        todo->due.type = sqlite3_column_int(stmt, count++);
-       if (todo->due.type == CALENDAR_TIME_UTIME)
-       {
+       if (todo->due.type == CALENDAR_TIME_UTIME) {
                todo->due.time.utime = sqlite3_column_int64(stmt,count++);
                count++; // due_datetime
-       }
-       else
-       {
+       } else {
                count++;
                temp = sqlite3_column_text(stmt, count++);
                if (temp) {
@@ -1623,14 +1536,13 @@ static void _cal_db_todo_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar
        sqlite3_column_int(stmt,count++);
 
        //has_extended
-       if (extended != NULL)
+       if (extended)
                *extended = sqlite3_column_int(stmt,count++);
 
        todo->freq = sqlite3_column_int(stmt, count++);
        todo->is_allday = sqlite3_column_int(stmt, count++);
 
-       if (is_view_table == true)
-       {
+       if (is_view_table == true) {
                if (todo->freq <= 0) {
                        //todo->rrule_id = 0;
                        //sqlite3_finalize(stmt);
@@ -1644,8 +1556,7 @@ static void _cal_db_todo_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar
                todo->until.time.utime = sqlite3_column_int64(stmt, count++);
 
                temp = sqlite3_column_text(stmt, count++);
-               if (CALENDAR_TIME_LOCALTIME == todo->until.type)
-               {
+               if (CALENDAR_TIME_LOCALTIME == todo->until.type) {
                        sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME,
                                        &todo->until.time.date.year,
                                        &todo->until.time.date.month,
@@ -1699,8 +1610,7 @@ static void _cal_db_todo_get_property_stmt(sqlite3_stmt *stmt,
 
        todo = (cal_todo_s*)(record);
 
-       switch (property)
-       {
+       switch (property) {
        case CAL_PROPERTY_TODO_ID:
                todo->index = sqlite3_column_int(stmt, *stmt_count);
                break;
@@ -1833,14 +1743,11 @@ static void _cal_db_todo_get_property_stmt(sqlite3_stmt *stmt,
        case CAL_PROPERTY_TODO_START:
                //!!
                todo->start.type = sqlite3_column_int(stmt,*stmt_count);
-               if (todo->start.type == CALENDAR_TIME_UTIME)
-               {
+               if (todo->start.type == CALENDAR_TIME_UTIME) {
                        *stmt_count = *stmt_count+1;
                        todo->start.time.utime = sqlite3_column_int64(stmt,*stmt_count);
                        *stmt_count = *stmt_count+1; // dtstart_datetime
-               }
-               else
-               {
+               } else {
                        *stmt_count = *stmt_count+1; // dtstart_utime
                        *stmt_count = *stmt_count+1;
                        temp = sqlite3_column_text(stmt, *stmt_count);
@@ -1859,14 +1766,11 @@ static void _cal_db_todo_get_property_stmt(sqlite3_stmt *stmt,
        case CAL_PROPERTY_TODO_DUE:
                //!!
                todo->due.type = sqlite3_column_int(stmt, *stmt_count);
-               if (todo->due.type == CALENDAR_TIME_UTIME)
-               {
+               if (todo->due.type == CALENDAR_TIME_UTIME) {
                        *stmt_count = *stmt_count+1;
                        todo->due.time.utime = sqlite3_column_int64(stmt,*stmt_count);
                        *stmt_count = *stmt_count+1; // due_datetime
-               }
-               else
-               {
+               } else {
                        *stmt_count = *stmt_count+1; // due_utime
                        *stmt_count = *stmt_count+1;
                        temp = sqlite3_column_text(stmt, *stmt_count);
@@ -1908,8 +1812,7 @@ static void _cal_db_todo_get_projection_stmt(sqlite3_stmt *stmt,
        int i=0;
        int stmt_count = 0;
 
-       for(i=0;i<projection_count;i++)
-       {
+       for(i=0;i<projection_count;i++) {
                _cal_db_todo_get_property_stmt(stmt,projection[i],&stmt_count,record);
        }
 }
@@ -1974,8 +1877,7 @@ static int _cal_db_todo_update_dirty(calendar_record_h record)
 
        ret = _cal_db_todo_get_record(todo_id, &original_record);
 
-       if (CALENDAR_ERROR_NONE == ret)
-       {
+       if (CALENDAR_ERROR_NONE == ret) {
                cal_record_s *_record = NULL;
                const cal_property_info_s* property_info = NULL;
                int property_info_count = 0;
@@ -1985,12 +1887,9 @@ static int _cal_db_todo_update_dirty(calendar_record_h record)
 
                property_info = cal_view_get_property_info(_record->view_uri, &property_info_count);
 
-               for(i=0;i<property_info_count;i++)
-               {
-                       if (true == cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY))
-                       {
-                               if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
-                               {
+               for(i=0;i<property_info_count;i++) {
+                       if (true == cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY)) {
+                               if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true) {
                                        int tmp=0;
                                        ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
                                        if (CALENDAR_ERROR_NONE != ret)
@@ -1999,8 +1898,7 @@ static int _cal_db_todo_update_dirty(calendar_record_h record)
                                        if (CALENDAR_ERROR_NONE != ret)
                                                continue;
                                }
-                               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
-                               {
+                               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true) {
                                        char *tmp=NULL;
                                        ret = calendar_record_get_str_p(record,property_info[i].property_id,&tmp);
                                        if (CALENDAR_ERROR_NONE != ret)
@@ -2009,8 +1907,7 @@ static int _cal_db_todo_update_dirty(calendar_record_h record)
                                        if (CALENDAR_ERROR_NONE != ret)
                                                continue;
                                }
-                               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
-                               {
+                               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
                                        double tmp=0;
                                        ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
                                        if (CALENDAR_ERROR_NONE != ret)
@@ -2019,8 +1916,7 @@ static int _cal_db_todo_update_dirty(calendar_record_h record)
                                        if (CALENDAR_ERROR_NONE != ret)
                                                continue;
                                }
-                               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
-                               {
+                               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true) {
                                        long long int tmp=0;
                                        ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
                                        if (CALENDAR_ERROR_NONE != ret)
@@ -2029,8 +1925,7 @@ static int _cal_db_todo_update_dirty(calendar_record_h record)
                                        if (CALENDAR_ERROR_NONE != ret)
                                                continue;
                                }
-                               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
-                               {
+                               else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
                                        calendar_time_s tmp = {0,};
                                        ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
                                        if (CALENDAR_ERROR_NONE != ret)
@@ -2051,10 +1946,8 @@ static int _cal_db_todo_update_dirty(calendar_record_h record)
                cal_list_clone((calendar_list_h)tmp_src->attendee_list, (calendar_list_h *)&tmp->attendee_list);
                cal_list_clone((calendar_list_h)tmp_src->extended_list, (calendar_list_h *)&tmp->extended_list);
 
-       }
-       else
-       {
-               DBG("get_record fail");
+       } else {
+               DBG("get_record Fail");
                return ret;
        }
 
index 8098ed7..91da19f 100644 (file)
@@ -108,11 +108,9 @@ int cal_db_query_create_projection(calendar_query_h query, char **projection)
        if (field_name)
                cal_db_append_string(&out_projection, (char*)field_name);
 
-       for (i=1;i<query_s->projection_count;i++)
-       {
+       for (i=1;i<query_s->projection_count;i++) {
                field_name = _cal_db_query_get_property_field_name(properties, query_s->property_count, query_s->projection[i]);
-               if (field_name)
-               {
+               if (field_name) {
                        cal_db_append_string(&out_projection, ",");
                        cal_db_append_string(&out_projection, (char*)field_name);
                }
@@ -138,18 +136,15 @@ int cal_db_query_create_order(calendar_query_h query, char *condition, char **or
                return CALENDAR_ERROR_NO_DATA;
 
        field_name = _cal_db_query_get_property_field_name(properties, query_s->property_count, query_s->sort_property_id);
-       if (CAL_PROPERTY_CHECK_DATA_TYPE(query_s->sort_property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true && field_name)
-       {
+       if (CAL_PROPERTY_CHECK_DATA_TYPE(query_s->sort_property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true && field_name) {
                const char *p_utime = NULL;
                const char *p_datetime = NULL;
 
                p_utime = _cal_db_query_get_utime_field_name(field_name);
                p_datetime = _cal_db_query_get_datetime_field_name(field_name);
 
-               if (!p_utime && !p_datetime)
-               {
-                       if (condition)
-                       {
+               if (!p_utime && !p_datetime) {
+                       if (condition) {
                                p_utime = _cal_db_query_get_utime_field_name(condition);
                                p_datetime = _cal_db_query_get_datetime_field_name(condition);
                        }
@@ -161,8 +156,7 @@ int cal_db_query_create_order(calendar_query_h query, char *condition, char **or
 
                if (p_utime && p_datetime) {
                        cal_record_type_e type = cal_view_get_type(query_s->view_uri);
-                       switch (type)
-                       {
+                       switch (type) {
                        case CAL_RECORD_TYPE_INSTANCE_NORMAL_EXTENDED:
                        case CAL_RECORD_TYPE_INSTANCE_NORMAL:
                                snprintf(out_order, sizeof(out_order), "ORDER BY %s %s ", p_utime, query_s->asc==false ? "DESC":"ASC");
@@ -219,12 +213,11 @@ int cal_db_query_create_projection_update_set(calendar_record_h record, char **s
        const char *field_name;
        int ret = CALENDAR_ERROR_NONE;
 
-       RETV_IF(record == NULL, -1);
+       RETV_IF(NULL == record, -1);
 
        _record = (cal_record_s *)record;
 
-       if (_record->properties_max_count == 0 || _record->properties_flags == NULL)
-       {
+       if (_record->properties_max_count == 0 || NULL == _record->properties_flags) {
                DBG("record don't have properties");
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
@@ -232,68 +225,56 @@ int cal_db_query_create_projection_update_set(calendar_record_h record, char **s
        // uri를 í†µí•´, property_info_s ê°€ì ¸ì˜´
        property_info = cal_view_get_property_info(_record->view_uri, &property_info_count);
 
-       for(i=0;i<property_info_count;i++)
-       {
-               if (true == cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY))
-               {
+       for(i=0;i<property_info_count;i++) {
+               if (true == cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY)) {
                        field_name = property_info[i].fields;
 
-                       if (field_name == NULL)
-                       {
+                       if (NULL == field_name) {
                                continue;
                        }
 
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
-                       {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true) {
                                int tmp=0;
                                ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (strlen(out_set) != 0)
-                               {
+                               if (strlen(out_set) != 0) {
                                        len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                }
                                len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d",field_name,tmp);
                        }
-                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
-                       {
+                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true) {
                                char *tmp=NULL;
                                ret = calendar_record_get_str(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (strlen(out_set) != 0)
-                               {
+                               if (strlen(out_set) != 0) {
                                        len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                }
                                len += snprintf(out_set+len, sizeof(out_set)-len, "%s=?",field_name);
                                *bind_text = g_slist_append(*bind_text, tmp);
                        }
-                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
-                       {
+                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
                                double tmp=0;
                                ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (strlen(out_set) != 0)
-                               {
+                               if (strlen(out_set) != 0) {
                                        len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                }
                                len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lf",field_name,tmp);
                        }
-                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
-                       {
+                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true) {
                                long long int tmp=0;
                                ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (strlen(out_set) != 0)
-                               {
+                               if (strlen(out_set) != 0) {
                                        len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                }
                                len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lld",field_name,tmp);
                        }
-                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
-                       {
+                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
                                /*
                                 * field_name
                                 * dtstart_type, dtstart_utime, dtstart_datetime
@@ -313,17 +294,14 @@ int cal_db_query_create_projection_update_set(calendar_record_h record, char **s
                                ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (tmp.type == CALENDAR_TIME_UTIME)
-                               {
-                                       if (strlen(out_set) != 0)
-                                       {
+                               if (tmp.type == CALENDAR_TIME_UTIME) {
+                                       if (strlen(out_set) != 0) {
                                                len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                        }
                                        len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=%lld",
                                                        timetype_field, CALENDAR_TIME_UTIME, utime_field, tmp.time.utime);
                                }
-                               else
-                               {
+                               else {
                                        char *bind_tmp = NULL;
                                        char bind_datetime[32] = {0};
                                        snprintf(bind_datetime, sizeof(bind_datetime), CAL_FORMAT_LOCAL_DATETIME,
@@ -334,8 +312,7 @@ int cal_db_query_create_projection_update_set(calendar_record_h record, char **s
                                                        tmp.time.date.minute,
                                                        tmp.time.date.second);
 
-                                       if (strlen(out_set) != 0)
-                                       {
+                                       if (strlen(out_set) != 0) {
                                                len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                        }
                                        len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=?",
@@ -367,91 +344,76 @@ int cal_db_query_create_projection_update_set_with_property(
        const char *field_name;
        int ret = CALENDAR_ERROR_NONE;
 
-       RETV_IF(record == NULL, -1);
+       RETV_IF(NULL == record, -1);
 
        _record = (cal_record_s *)record;
 
-       if (_record->properties_max_count == 0 || _record->properties_flags == NULL)
-       {
+       if (_record->properties_max_count == 0 || NULL == _record->properties_flags) {
                return CALENDAR_ERROR_NONE;
        }
 
        // uri를 í†µí•´, property_info_s ê°€ì ¸ì˜´
        property_info = cal_view_get_property_info(_record->view_uri, &property_info_count);
 
-       for(i=0;i<property_info_count;i++)
-       {
+       for(i=0;i<property_info_count;i++) {
                int j=0;
                bool flag = false;
-               for(j=0;j<properties_count;j++)
-               {
-                       if (property_info[i].property_id == properties[j])
-                       {
+               for(j=0;j<properties_count;j++) {
+                       if (property_info[i].property_id == properties[j]) {
                                flag = true;
                                break;
                        }
                }
                if (true == flag &&
-                               (true == cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY)))
-               {
+                               (true == cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY))) {
                        field_name = property_info[i].fields;
 
-                       if (field_name == NULL)
-                       {
+                       if (NULL == field_name) {
                                continue;
                        }
 
-                       if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
-                       {
+                       if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true) {
                                int tmp=0;
                                ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (strlen(out_set) != 0)
-                               {
+                               if (strlen(out_set) != 0) {
                                        len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                }
                                len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d",field_name,tmp);
                        }
-                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
-                       {
+                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true) {
                                char *tmp=NULL;
                                ret = calendar_record_get_str(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (strlen(out_set) != 0)
-                               {
+                               if (strlen(out_set) != 0) {
                                        len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                }
                                len += snprintf(out_set+len, sizeof(out_set)-len, "%s=?",field_name);
                                *bind_text = g_slist_append(*bind_text, tmp);
                        }
-                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
-                       {
+                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
                                double tmp=0;
                                ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (strlen(out_set) != 0)
-                               {
+                               if (strlen(out_set) != 0) {
                                        len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                }
                                len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lf",field_name,tmp);
                        }
-                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
-                       {
+                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true) {
                                long long int tmp=0;
                                ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (strlen(out_set) != 0)
-                               {
+                               if (strlen(out_set) != 0) {
                                        len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                }
                                len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lld",field_name,tmp);
                        }
-                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
-                       {
+                       else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
                                /*
                                 * field_name
                                 * dtstart_type, dtstart_utime, dtstart_datetime
@@ -471,17 +433,14 @@ int cal_db_query_create_projection_update_set_with_property(
                                ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
                                if (CALENDAR_ERROR_NONE != ret)
                                        continue;
-                               if (tmp.type == CALENDAR_TIME_UTIME)
-                               {
-                                       if (strlen(out_set) != 0)
-                                       {
+                               if (tmp.type == CALENDAR_TIME_UTIME) {
+                                       if (strlen(out_set) != 0) {
                                                len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                        }
                                        len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=%lld",
                                                        timetype_field,CALENDAR_TIME_UTIME,utime_field,tmp.time.utime);
                                }
-                               else
-                               {
+                               else {
                                        char *bind_tmp = NULL;
                                        char bind_datetime[32] = {0};
                                        snprintf(bind_datetime, sizeof(bind_datetime), CAL_FORMAT_LOCAL_DATETIME,
@@ -492,8 +451,7 @@ int cal_db_query_create_projection_update_set_with_property(
                                                        tmp.time.date.minute,
                                                        tmp.time.date.second);
 
-                                       if (strlen(out_set) != 0)
-                                       {
+                                       if (strlen(out_set) != 0) {
                                                len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
                                        }
                                        len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=?",
@@ -522,24 +480,19 @@ static int _cal_db_query_create_composite_condition(cal_composite_filter_s *com_
        cal_filter_s *filter;
        int ret = CALENDAR_ERROR_NONE;
 
-       if (com_filter == NULL || com_filter->filters == NULL)
-       {
+       if (NULL == com_filter || NULL == com_filter->filters) {
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
        filter = (cal_filter_s *)com_filter->filters->data;
-       if (filter->filter_type == CAL_FILTER_COMPOSITE)
-       {
+       if (filter->filter_type == CAL_FILTER_COMPOSITE) {
                ret = _cal_db_query_create_composite_condition((cal_composite_filter_s*)filter, &cond, &binds);
-       }
-       else
-       {
+       } else {
                ret = _cal_db_query_create_attribute_condition(com_filter, (cal_attribute_filter_s*)filter, &cond, &binds);
        }
 
-       if (CALENDAR_ERROR_NONE != ret)
-       {
-               ERR("_cal_db_query_create_attribute_condition fail");
+       if (CALENDAR_ERROR_NONE != ret) {
+               ERR("_cal_db_query_create_attribute_condition Fail");
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
@@ -552,24 +505,17 @@ static int _cal_db_query_create_composite_condition(cal_composite_filter_s *com_
        CAL_FREE(cond);
 
        for(cursor_ops=com_filter->filter_ops; cursor_ops && cursor_filter;
-                       cursor_filter=cursor_filter->next, cursor_ops=cursor_ops->next)
-       {
+                       cursor_filter=cursor_filter->next, cursor_ops=cursor_ops->next) {
                filter = (cal_filter_s *)cursor_filter->data;
                if (filter->filter_type == CAL_FILTER_COMPOSITE)
-               {
                        ret = _cal_db_query_create_composite_condition((cal_composite_filter_s*)filter, &cond, &binds2);
-               }
                else
-               {
                        ret = _cal_db_query_create_attribute_condition(com_filter, (cal_attribute_filter_s*)filter, &cond, &binds2);
-               }
 
-               if (CALENDAR_ERROR_NONE != ret)
-               {
-                       ERR("_cal_db_query_create_attribute_condition fail");
+               if (CALENDAR_ERROR_NONE != ret) {
+                       ERR("_cal_db_query_create_attribute_condition Fail");
                        CAL_FREE(out_cond);
-                       if (binds)
-                       {
+                       if (binds) {
                                g_slist_free_full(binds, free);
                                binds = NULL;
                        }
@@ -577,14 +523,12 @@ static int _cal_db_query_create_composite_condition(cal_composite_filter_s *com_
                }
 
                op = (calendar_filter_operator_e)cursor_ops->data;
-               if (op == CALENDAR_FILTER_OPERATOR_AND)
-               {
+               if (op == CALENDAR_FILTER_OPERATOR_AND) {
                        cal_db_append_string(&out_cond, "AND (");
                        cal_db_append_string(&out_cond, cond);
                        cal_db_append_string(&out_cond, ")");
                }
-               else
-               {
+               else {
                        cal_db_append_string(&out_cond, "OR (");
                        cal_db_append_string(&out_cond, cond);
                        cal_db_append_string(&out_cond, ")");
@@ -611,8 +555,7 @@ static int _cal_db_query_create_attribute_condition(cal_composite_filter_s *com_
 
        RETV_IF(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
 
-       switch (filter->filter_type)
-       {
+       switch (filter->filter_type) {
        case CAL_FILTER_INT:
                ret = _cal_db_query_create_int_condition(com_filter, filter, &cond);
                break;
@@ -650,8 +593,7 @@ static int _cal_db_query_create_int_condition(cal_composite_filter_s *com_filter
        RETVM_IF(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
                        "Invalid parameter : property id(%d)", filter->property_id);
 
-       switch (filter->match)
-       {
+       switch (filter->match) {
        case CALENDAR_MATCH_EQUAL:
                snprintf(out_cond, sizeof(out_cond), "%s = %d", field_name, filter->value.i);
                break;
@@ -693,8 +635,7 @@ static int _cal_db_query_create_double_condition(cal_composite_filter_s *com_fil
        RETVM_IF(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
                        "Invalid parameter : property id(%d)", filter->property_id);
 
-       switch (filter->match)
-       {
+       switch (filter->match) {
        case CALENDAR_MATCH_EQUAL:
                snprintf(out_cond, sizeof(out_cond), "%s = %lf", field_name, filter->value.d);
                break;
@@ -736,8 +677,7 @@ static int _cal_db_query_create_lli_condition(cal_composite_filter_s *com_filter
        RETVM_IF(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
                        "Invalid parameter : property id(%d)", filter->property_id);
 
-       switch (filter->match)
-       {
+       switch (filter->match) {
        case CALENDAR_MATCH_EQUAL:
                snprintf(out_cond, sizeof(out_cond), "%s = %lld", field_name, filter->value.lli);
                break;
@@ -780,15 +720,12 @@ static int _cal_db_query_create_caltime_condition(cal_composite_filter_s *com_fi
        RETVM_IF(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
                        "Invalid parameter : property id(%d)", filter->property_id);
 
-       if (filter->value.caltime.type == CALENDAR_TIME_UTIME)
-       {
+       if (filter->value.caltime.type == CALENDAR_TIME_UTIME) {
                tmp = _cal_db_query_get_utime_field_name(field_name);
-               if (tmp == NULL)
-               {
+               if (NULL == tmp) {
                        tmp = field_name;
                }
-               switch (filter->match)
-               {
+               switch (filter->match) {
                case CALENDAR_MATCH_EQUAL:
                        snprintf(out_cond, sizeof(out_cond), "%s = %lld", tmp, filter->value.caltime.time.utime);
                        break;
@@ -814,20 +751,16 @@ static int _cal_db_query_create_caltime_condition(cal_composite_filter_s *com_fi
                        ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
-       }
-       else if (filter->value.caltime.type == CALENDAR_TIME_LOCALTIME)
-       {
+       } else if (filter->value.caltime.type == CALENDAR_TIME_LOCALTIME) {
                char sdate[32] = {0};
                snprintf(sdate, sizeof(sdate), CAL_FORMAT_LOCAL_DATETIME,
                                filter->value.caltime.time.date.year, filter->value.caltime.time.date.month, filter->value.caltime.time.date.mday,
                                filter->value.caltime.time.date.hour, filter->value.caltime.time.date.minute, filter->value.caltime.time.date.second);
                tmp = _cal_db_query_get_datetime_field_name(field_name);
-               if (tmp == NULL)
-               {
+               if (NULL == tmp) {
                        tmp = field_name;
                }
-               switch (filter->match)
-               {
+               switch (filter->match) {
                case CALENDAR_MATCH_EQUAL:
                        snprintf(out_cond, sizeof(out_cond), "%s = '%s'", tmp, sdate);
                        break;
@@ -851,9 +784,7 @@ static int _cal_db_query_create_caltime_condition(cal_composite_filter_s *com_fi
                        ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
-       }
-       else
-       {
+       } else {
                ERR("Invalid parameter : property id(%d)", filter->property_id);
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
@@ -862,8 +793,7 @@ static int _cal_db_query_create_caltime_condition(cal_composite_filter_s *com_fi
        if (record_type != CAL_RECORD_TYPE_INSTANCE_NORMAL &&
                        record_type != CAL_RECORD_TYPE_INSTANCE_ALLDAY &&
                        record_type != CAL_RECORD_TYPE_INSTANCE_NORMAL_EXTENDED &&
-                       record_type != CAL_RECORD_TYPE_INSTANCE_ALLDAY_EXTENDED)
-       {
+                       record_type != CAL_RECORD_TYPE_INSTANCE_ALLDAY_EXTENDED) {
                int len = strlen(out_cond);
                const char *type_field = _cal_db_query_get_timetype_field_name(field_name);
                snprintf(out_cond + len, sizeof(out_cond) - len -1, " AND %s = %d ", type_field, filter->value.caltime.type);
@@ -904,8 +834,7 @@ static int _cal_db_query_create_str_condition(cal_composite_filter_s *com_filter
        RETVM_IF(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
                        "Invalid parameter : property id(%d)", filter->property_id);
 
-       switch (filter->match)
-       {
+       switch (filter->match) {
        case CALENDAR_MATCH_EXACTLY:
                snprintf(out_cond, sizeof(out_cond), "%s = ?", field_name);
                with_escape = false;
@@ -930,8 +859,7 @@ static int _cal_db_query_create_str_condition(cal_composite_filter_s *com_filter
                return CALENDAR_ERROR_INVALID_PARAMETER;
        }
 
-       if (filter->value.s)
-       {
+       if (filter->value.s) {
                *bind_text = g_slist_append(*bind_text,
                                _cal_db_get_str_with_escape(filter->value.s, strlen(filter->value.s), with_escape));
        }
@@ -943,11 +871,9 @@ static const char * _cal_db_query_get_property_field_name(const cal_property_inf
                int count, unsigned int property_id)
 {
        int i;
-       for (i=0;i<count;i++)
-       {
+       for (i=0;i<count;i++) {
                cal_property_info_s *p = (cal_property_info_s*)&(properties[i]);
-               if (property_id == p->property_id)
-               {
+               if (property_id == p->property_id) {
                        if (p->fields)
                                return p->fields;
                        else
@@ -962,11 +888,9 @@ static const char * _cal_db_query_get_utime_field_name(const char* src)
        char *tmp1 = NULL;
        int i=0;
 
-       for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++)
-       {
+       for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++) {
                tmp1 = strstr(src,_cal_db_utime_field_name[i]);
-               if (tmp1 != NULL)
-               {
+               if (tmp1) {
                        return _cal_db_utime_field_name[i];
                }
        }
@@ -979,11 +903,9 @@ static const char * _cal_db_query_get_datetime_field_name(const char* src)
        char *tmp1 = NULL;
        int i=0;
 
-       for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++)
-       {
+       for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++) {
                tmp1 = strstr(src,_cal_db_datetime_field_name[i]);
-               if (tmp1 != NULL)
-               {
+               if (tmp1) {
                        return _cal_db_datetime_field_name[i];
                }
        }
@@ -996,11 +918,9 @@ static const char * _cal_db_query_get_timetype_field_name(const char* src)
        char *tmp1 = NULL;
        int i=0;
 
-       for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++)
-       {
+       for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++) {
                tmp1 = strstr(src,_cal_db_timetype_field_name[i]);
-               if (tmp1 != NULL)
-               {
+               if (tmp1) {
                        return _cal_db_timetype_field_name[i];
                }
        }
index 995a00c..74aae25 100644 (file)
@@ -28,7 +28,7 @@
 void cal_db_rrule_set_default(calendar_record_h record)
 {
        cal_event_s *event = NULL;
-       RET_IF(record == NULL);
+       RET_IF(NULL == record);
 
        event = (cal_event_s *)record;
 
@@ -39,9 +39,7 @@ void cal_db_rrule_set_default(calendar_record_h record)
                break;
        case CALENDAR_RECURRENCE_WEEKLY:
                if (event->byday && 0 < strlen(event->byday))
-               {
                        break;
-               }
 
                event->byday = cal_time_extract_by(event->system_type, event->start_tzid, event->wkst,
                                &event->start, CAL_DAY_OF_WEEK);
@@ -90,14 +88,14 @@ void cal_db_rrule_get_rrule_from_event(calendar_record_h event, cal_rrule_s **rr
        cal_rrule_s *_rrule;
        cal_event_s *_event;
 
-       RET_IF(event == NULL);
+       RET_IF(NULL == event);
        _event = (cal_event_s *)event;
        if (_event->freq == CALENDAR_RECURRENCE_NONE) {
                return;
        }
 
        _rrule = calloc(1, sizeof(cal_rrule_s));
-       RETM_IF(_rrule == NULL, "calloc() Fail");
+       RETM_IF(NULL == _rrule, "calloc() Fail");
 
        _rrule->freq = _event->freq;
 
@@ -132,8 +130,8 @@ void cal_db_rrule_set_rrule_to_event(cal_rrule_s *rrule, calendar_record_h event
 {
        cal_event_s *_event;
 
-       RET_IF(rrule == NULL);
-       RET_IF(event == NULL);
+       RET_IF(NULL == rrule);
+       RET_IF(NULL == event);
 
        _event = (cal_event_s *)event;
 
@@ -158,8 +156,8 @@ void cal_db_rrule_set_rrule_to_todo(cal_rrule_s *rrule, calendar_record_h todo)
 {
        cal_todo_s *_todo;
 
-       RET_IF(rrule == NULL);
-       RET_IF(todo == NULL);
+       RET_IF(NULL == rrule);
+       RET_IF(NULL == todo);
 
        _todo = (cal_todo_s *)todo;
 
@@ -185,12 +183,12 @@ void cal_db_rrule_get_rrule_from_todo(calendar_record_h todo, cal_rrule_s **rrul
        cal_rrule_s *_rrule;
        cal_todo_s *_todo;
 
-       RET_IF(todo == NULL);
+       RET_IF(NULL == todo);
 
        _todo = (cal_todo_s *)todo;
 
        _rrule = calloc(1, sizeof(cal_rrule_s));
-       RETM_IF(_rrule == NULL, "calloc() Fail");
+       RETM_IF(NULL == _rrule, "calloc() Fail");
 
        _rrule->freq = _todo->freq;
        _rrule->range_type = _todo->range_type;
@@ -213,6 +211,8 @@ void cal_db_rrule_get_rrule_from_todo(calendar_record_h todo, cal_rrule_s **rrul
 
 int _cal_db_rrule_insert_record(int id, cal_rrule_s *rrule)
 {
+       RETV_IF(NULL == rrule, CALENDAR_ERROR_INVALID_PARAMETER);
+
        int rrule_id;
        int index;
        char query[CAL_DB_SQL_MAX_LEN] = {0};
@@ -355,8 +355,7 @@ int cal_db_rrule_get_rrule(int id, cal_rrule_s **rrule)
        }
 
        _rrule = calloc(1, sizeof(cal_rrule_s));
-       RETVM_IF(_rrule == NULL, CALENDAR_ERROR_OUT_OF_MEMORY,
-                       "calloc() Fail");
+       RETVM_IF(NULL == _rrule, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
 
        index = 0;
        sqlite3_column_int(stmt, index++); // id
@@ -569,7 +568,7 @@ static int _cal_db_rrule_update_record(int id, cal_rrule_s *rrule)
 
 int cal_db_rrule_insert_record(int id, cal_rrule_s *rrule)
 {
-       RETVM_IF(rrule == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
+       RETVM_IF(NULL == rrule, CALENDAR_ERROR_INVALID_PARAMETER,
                        "Invalid argument: rrule is NULL");
 
        if (rrule->freq == CALENDAR_RECURRENCE_NONE) {
index cf8db52..b60d51a 100644 (file)
@@ -181,7 +181,7 @@ int cal_db_util_query_get_first_int_result(const char *query, GSList *bind_text,
                {
                        retry = false;
                }
-       } while(retry);
+       } while (retry);
 
        if (SQLITE_OK != ret)
        {
@@ -230,8 +230,9 @@ int cal_db_util_query_get_first_int_result(const char *query, GSList *bind_text,
                                retry = false;
                        }
                }
-               else
+               else {
                        if (result) *result = sqlite3_column_int(stmt, 0);
+               }
        } while(retry);
 
        sqlite3_finalize(stmt);
@@ -288,7 +289,7 @@ sqlite3_stmt* cal_db_util_query_prepare(char *query)
                {
                        retry = false;
                }
-       } while(retry);
+       } while (retry);
 
        return stmt;
 }
@@ -317,7 +318,7 @@ cal_db_util_error_e cal_db_util_stmt_step(sqlite3_stmt *stmt)
                {
                        retry = false;
                }
-       } while(retry);
+       } while (retry);
 
        switch (ret)
        {
@@ -351,8 +352,7 @@ cal_db_util_error_e cal_db_util_stmt_step(sqlite3_stmt *stmt)
 #define CAL_COMMIT_TRY_MAX 500000
 int cal_db_util_begin_trans(void)
 {
-       if (transaction_cnt <= 0)
-       {
+       if (transaction_cnt <= 0) {
                int ret, progress;
 
                progress = 100000;
index cc5521c..a35d9f0 100644 (file)
@@ -61,7 +61,7 @@ static int _cal_server_alarm_unset_alerted_alarmmgr_id(int alarm_id)
        ret = cal_db_util_begin_trans();
        if (CALENDAR_ERROR_NONE != ret)
        {
-               ERR("cal_db_util_begin_trans() failed");
+               ERR("cal_db_util_begin_trans() Fail");
                return CALENDAR_ERROR_DB_FAILED;
        }
 
@@ -97,7 +97,7 @@ static int _cal_server_alarm_clear_all_cb(alarm_id_t alarm_id, void *data)
        ret = alarmmgr_remove_alarm(alarm_id);
        if (ret != ALARMMGR_RESULT_SUCCESS)
        {
-               ERR("alarmmgr_remove_alarm() failed(ret:%d)", ret);
+               ERR("alarmmgr_remove_alarm() Fail(ret:%d)", ret);
                return ret;
        }
        return CALENDAR_ERROR_NONE;
@@ -112,7 +112,7 @@ static int _cal_server_alarm_update_alarm_id(int alarm_id, int event_id, int tic
        ret = cal_db_util_begin_trans();
        if (CALENDAR_ERROR_NONE != ret)
        {
-               ERR("cal_db_util_begin_trans() failed");
+               ERR("cal_db_util_begin_trans() Fail");
                return CALENDAR_ERROR_DB_FAILED;
        }
 
@@ -279,11 +279,9 @@ static int _cal_server_alarm_get_alert_time(int alarm_id, time_t *tt_alert)
        current += (tick * unit);
        current -= 2; // in case time passed
 
-       switch (record_type)
-       {
+       switch (record_type) {
        case CALENDAR_BOOK_TYPE_EVENT:
-               switch (dtstart_type)
-               {
+               switch (dtstart_type) {
                case CALENDAR_TIME_UTIME:
                        utime = _cal_server_alarm_get_alert_utime("dtstart_utime", event_id, current);
                        break;
@@ -295,8 +293,7 @@ static int _cal_server_alarm_get_alert_time(int alarm_id, time_t *tt_alert)
                break;
 
        case CALENDAR_BOOK_TYPE_TODO:
-               switch (dtend_type)
-               {
+               switch (dtend_type) {
                case CALENDAR_TIME_UTIME:
                        utime = _cal_server_alarm_get_alert_utime("dtend_utime", event_id, current);
                        break;
@@ -689,7 +686,7 @@ static int _cal_server_alarm_register(GList *alarm_list)
        ret = alarmmgr_enum_alarm_ids(_cal_server_alarm_clear_all_cb, NULL);
        if (ret != ALARMMGR_RESULT_SUCCESS)
        {
-               ERR("alarmmgr_enum_alarm_ids() failed");
+               ERR("alarmmgr_enum_alarm_ids() Fail");
                return ret;
        }
 
@@ -704,8 +701,7 @@ static int _cal_server_alarm_register(GList *alarm_list)
        tzset();
        struct tm st_alarm = {0};
 
-       switch (ad->system_type)
-       {
+       switch (ad->system_type) {
        case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
                gmtime_r(&mod_time, &st_alarm);
                break;
@@ -730,9 +726,8 @@ static int _cal_server_alarm_register(GList *alarm_list)
 
        int alarm_id = 0;
        ret = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id);
-       if (ret < 0)
-       {
-               ERR("alarmmgr_add_alarm_with_localtime failed (%d)", ret);
+       if (ret < 0) {
+               ERR("alarmmgr_add_alarm_with_localtime Fail (%d)", ret);
                alarmmgr_free_alarm(alarm_info);
                return ret;
        }
@@ -916,7 +911,7 @@ static int _cal_server_alarm_register_with_alarmmgr(time_t utime)
 
        // free list
        l = g_list_first(l);
-       while(l) {
+       while (l) {
                struct _alarm_data_s *ad = (struct _alarm_data_s *)l->data;
                free(ad);
                l = g_list_next(l);
@@ -1002,10 +997,10 @@ int cal_server_alarm(void)
        _cal_server_alarm_set_inotify(__changed_cb);
 
        ret = alarmmgr_init("calendar-service");
-       RETVM_IF(ret < 0, ret, "alarmmgr_init() failed");
+       RETVM_IF(ret < 0, ret, "alarmmgr_init() Fail");
 
        ret = alarmmgr_set_cb(_alert_cb, NULL);
-       RETVM_IF(ret < 0, ret, "alarmmgr_set_cb() failed");
+       RETVM_IF(ret < 0, ret, "alarmmgr_set_cb() Fail");
 
        _cal_server_alarm_register_with_alarmmgr(time(NULL));
 
index eb91579..27b1121 100644 (file)
@@ -64,12 +64,10 @@ static bool _cal_server_calendar_delete_step(int ret, __calendar_delete_data_s*
                        g_list_free(data->calendar_id_list);
 
                CAL_FREE(data);
-               ERR("fail (%d)",ret);
-
+               ERR("_cal_server_calendar_delete_step Fail(%d)",ret);
                return false;
        }
-       switch (data->step)
-       {
+       switch (data->step) {
        case STEP_1:
                if (ret == CALENDAR_ERROR_NO_DATA) {
                        if (data->calendar_id_list)
@@ -107,8 +105,7 @@ static int _cal_server_calendar_delete_step1(__calendar_delete_data_s* data)
 
        CAL_FN_CALL();
 
-       if (data->calendar_id_list == NULL)
-       {
+       if (NULL == data->calendar_id_list) {
                // get event_list
                snprintf(query, sizeof(query), "SELECT id FROM %s "
                                "WHERE deleted = 1",
@@ -120,8 +117,7 @@ static int _cal_server_calendar_delete_step1(__calendar_delete_data_s* data)
                        ERR("cal_db_util_query_prepare() Fail");
                        return CALENDAR_ERROR_DB_FAILED;
                }
-               while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
-               {
+               while(CAL_DB_ROW == cal_db_util_stmt_step(stmt)) {
                        int id = 0;
                        id = sqlite3_column_int(stmt, 0);
                        data->calendar_id_list = g_list_append(data->calendar_id_list, GINT_TO_POINTER(id));
@@ -168,18 +164,17 @@ static int _cal_server_calendar_delete_step2(__calendar_delete_data_s* data)
        }
 
        // get event_list
-       snprintf(query, sizeof(query), "SELECT id FROM %s "
-                       "WHERE calendar_id = %d LIMIT %d",
+       snprintf(query, sizeof(query), "SELECT id FROM %s WHERE calendar_id = %d LIMIT %d",
                        CAL_TABLE_SCHEDULE,
                        data->current_calendar_id, CAL_SERVER_CALENDAR_DELETE_COUNT);
 
        stmt = cal_db_util_query_prepare(query);
-       if (NULL == stmt)
-       {
+       if (NULL == stmt) {
                ERR("cal_db_util_query_prepare() Fail");
                cal_db_util_end_trans(false);
                return CALENDAR_ERROR_DB_FAILED;
        }
+
        while(CAL_DB_ROW == cal_db_util_stmt_step(stmt))
        {
                int id = 0;
@@ -198,8 +193,7 @@ static int _cal_server_calendar_delete_step2(__calendar_delete_data_s* data)
        }
 
        GList *cursor = g_list_first(list);
-       while(cursor)
-       {
+       while(cursor) {
                int id = GPOINTER_TO_INT(cursor->data);
                /* delete event table */
                snprintf(query, sizeof(query), "DELETE FROM %s "
@@ -282,15 +276,12 @@ static bool  _cal_server_calendar_run(__calendar_delete_data_s* data)
 
        CAL_FN_CALL();
 
-       if (data == NULL)
-       {
+       if (data == NULL) {
                ERR("data is NULL");
-
                return false;
        }
 
-       switch (data->step)
-       {
+       switch (data->step) {
        case STEP_1:
                ret = _cal_server_calendar_delete_step1(data);
                break;
@@ -314,31 +305,26 @@ static bool  _cal_server_calendar_run(__calendar_delete_data_s* data)
 
 }
 
-static gpointer  _cal_server_calendar_main(gpointer user_data)
+static gpointer _cal_server_calendar_main(gpointer user_data)
 {
        __calendar_delete_data_s *callback_data = NULL;
        int ret = CALENDAR_ERROR_NONE;
        CAL_FN_CALL();
 
-       while(1)
-       {
+       while(1) {
                callback_data = calloc(1,sizeof(__calendar_delete_data_s));
 
-               if (callback_data != NULL)
-               {
+               if (callback_data != NULL) {
                        callback_data->step = STEP_1;
 
                        // delete
-                       while(1)
-                       {
+                       while(1) {
                                ret = calendar_connect();
-                               if (CALENDAR_ERROR_NONE != ret)
-                               {
+                               if (CALENDAR_ERROR_NONE != ret) {
                                        break;
                                }
                                sleep(CAL_SERVER_CALENDAR_DELETE_STEP_TIME); // sleep 1 sec.
-                               if (_cal_server_calendar_run(callback_data) == false)
-                               {
+                               if (_cal_server_calendar_run(callback_data) == false) {
                                        callback_data = NULL;
                                        DBG("end");
                                        break;
@@ -347,10 +333,11 @@ static gpointer  _cal_server_calendar_main(gpointer user_data)
                        calendar_disconnect();
                        CAL_FREE(callback_data);
                }
-               else
-               {
+               else {
                        ERR("calloc fail");
                }
+               calendar_disconnect();
+               CAL_FREE(callback_data);
 
                g_mutex_lock(&_cal_server_calendar_delete_mutex);
                DBG("wait");
@@ -365,11 +352,11 @@ void cal_server_calendar_delete_start(void)
 {
        CAL_FN_CALL();
 
-       if (_cal_server_calendar_delete_thread == NULL)
-       {
+       if (NULL == _cal_server_calendar_delete_thread) {
                g_mutex_init(&_cal_server_calendar_delete_mutex);
                g_cond_init(&_cal_server_calendar_delete_cond);
-               _cal_server_calendar_delete_thread = g_thread_new(CAL_SERVER_CALENDAR_DELETE_THREAD_NAME,_cal_server_calendar_main,NULL);
+               _cal_server_calendar_delete_thread = g_thread_new(CAL_SERVER_CALENDAR_DELETE_THREAD_NAME,
+                               _cal_server_calendar_main, NULL);
        }
 
        // don't use mutex.
index a9dd9b9..7dd88c1 100644 (file)
@@ -444,7 +444,7 @@ void cal_server_contacts_delete(int account_id)
                calendar_list_first(list);
                do {
                        if (calendar_list_get_current_record_p(list, &event) == CALENDAR_ERROR_NONE) {
-                               if (event == NULL) {
+                               if (NULL == event) {
                                        DBG("No event\n");
                                        break;
                                }
@@ -500,7 +500,7 @@ void cal_server_contacts_sync_start(void)
 {
        CAL_FN_CALL();
 
-       if (_cal_server_contacts_sync_thread == NULL) {
+       if (NULL == _cal_server_contacts_sync_thread) {
                g_mutex_init(&_cal_server_contacts_sync_mutex);
                g_cond_init(&_cal_server_contacts_sync_cond);
                _cal_server_contacts_sync_thread = g_thread_new(CAL_SERVER_CONTACTS_SYNC_THREAD_NAME,
@@ -509,6 +509,5 @@ void cal_server_contacts_sync_start(void)
 
        // don't use mutex.
        g_cond_signal(&_cal_server_contacts_sync_cond);
-
-       return;
 }
+
index 65e7741..40e47f5 100644 (file)
@@ -54,13 +54,13 @@ static inline int __remake_db_file(char* db_path)
 
        fd = open(db_file, O_CREAT | O_RDWR, 0660);
        if (-1 == fd) {
-               ERR("open Failed ");
+               ERR("open Fail ");
                return -1;
        }
 
        ret = fchown(fd, getuid(), CAL_SECURITY_FILE_GROUP);
        if (-1 == ret) {
-               ERR("Failed to fchown ");
+               ERR("Fail to fchown ");
                close(fd);
                return -1;
        }
@@ -72,13 +72,13 @@ static inline int __remake_db_file(char* db_path)
 
        fd = open(jn_file, O_CREAT | O_RDWR, 0660);
        if (-1 == fd) {
-               ERR("open Failed ");
+               ERR("open Fail ");
                return -1;
        }
 
        ret = fchown(fd, getuid(), CAL_SECURITY_FILE_GROUP);
        if (-1 == ret) {
-               ERR("Failed to fchown ");
+               ERR("Fail to fchown ");
                close(fd);
                return -1;
        }
index 173bb25..4b7d0f7 100644 (file)
@@ -35,8 +35,7 @@ static int _cal_server_update_get_db_version(sqlite3 *db, int *version)
 
        snprintf(query, sizeof(query), "PRAGMA user_version;");
        ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
-       if (SQLITE_OK != ret)
-       {
+       if (SQLITE_OK != ret) {
                ERR("sqlite3_prepare_v2() failed[%s]", sqlite3_errmsg(db));
                return CALENDAR_ERROR_DB_FAILED;
        }
@@ -73,8 +72,7 @@ int cal_server_update(void)
        _cal_server_update_get_db_version(__db, &old_version);
        DBG("[%s] old version(%d)", db_file, old_version);
 
-       if (old_version < 100)
-       {
+       if (old_version < 100) {
                /* ----------------------- start modified 2013/08/22
                 * added attendee_table(cutype, delegatee_uri, member), alarm_table(summary, action, attach).
                 */
@@ -126,8 +124,7 @@ int cal_server_update(void)
                /* ----------------------- end modified 2013/08/22
                 */
        }
-       if (old_version == 100)
-       {
+       if (old_version == 100) {
                /* ----------------------- start modified 2013/09/22
                 * added schedule_table(freq) for view table parameter.
                 */
@@ -141,8 +138,7 @@ int cal_server_update(void)
                /* ----------------------- end modified 2013/09/22
                 */
        }
-       if (old_version == 101)
-       {
+       if (old_version == 101) {
                /* ----------------------- start modified 2014/07/02
                 * added trigger depeding on schedule_table
                 * added original_event_id in deleted_table to check exception event.
@@ -227,8 +223,7 @@ int cal_server_update(void)
                 */
                old_version = 102;
        }
-       if (old_version == 102)
-       {
+       if (old_version == 102) {
                /* ----------------------- start modified 2014/10/24
                 * added field is_alldy on schedule_table
                 */
@@ -244,8 +239,7 @@ int cal_server_update(void)
                old_version = 103;
        }
 
-       if (old_version == 103)
-       {
+       if (old_version == 103) {
                ret = sqlite3_exec(__db, "DROP TABLE reminder_table", NULL, 0, &errmsg);
                if (SQLITE_OK != ret) {
                        ERR("DROP TABLE reminder_table failed(%d:%s)", ret, errmsg);
@@ -253,8 +247,7 @@ int cal_server_update(void)
                }
                old_version = 104;
        }
-       if (old_version == 104)
-       {
+       if (old_version == 104) {
                ret = sqlite3_exec(__db, "ALTER TABLE alarm_table ADD COLUMN alarm_utime INTEGER", NULL, 0, &errmsg);
                if (SQLITE_OK != ret) {
                        ERR("ALTER TABLE schedule_table failed(%d:%s)", ret, errmsg);