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;
printf("%c",c);
break;
}
- }while(EOF != c);
+ }while (EOF != c);
exit(EXIT_SUCCESS);
}
timerclear(&__g_release_time); \
} \
} \
-} while(0)
+} while (0)
#define CAL_LIMIT_ACCESS_BACK \
do { \
{ \
gettimeofday(&__g_release_time, NULL); \
} \
- } while(0)
+ } while (0)
static int __g_access_count;
// 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;
}
// 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) {
// 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) {
// 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) {
// 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) {
// 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) {
// 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;
}
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);
}
{
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);
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;
}
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;
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
}
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;
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;
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;
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 ;
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;
}
noti_list = NULL;
}
- if (0 <= inoti_fd)
- {
+ if (0 <= inoti_fd) {
close(inoti_fd);
inoti_fd = -1;
}
if (ptr) \
free(ptr); \
ptr = NULL; \
- } while(0)
+ } while (0)
// Thread-local storage
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;
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;
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);
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);
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;
}
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);
}
return ret;
}
-
mutex = _cal_mutex_get_mutex(type);
- if (mutex != NULL)
- {
+ if (mutex) {
ret = pthread_mutex_lock(mutex);
RETM_IF(ret, "mutex_lock Failed(%d)", ret);
}
mutex = _cal_mutex_get_mutex(type);
- if (mutex != NULL)
- {
+ if (mutex) {
ret = pthread_mutex_unlock(mutex);
RETM_IF(ret, "mutex_unlock Failed(%d)", ret);
}
{
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;
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);
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;
}
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);
}
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);
}
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);
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:
_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 ;
}
}
_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
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);
}
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));
}
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;
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;
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;
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;
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;
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;
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;
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;
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;
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);
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:
(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:
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;
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;
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;
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;
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);
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;
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;
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;
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;
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);
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;
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;
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;
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);
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;
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;
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;
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;
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);
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
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;
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);
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;
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;
{
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;
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;
int i;
UErrorCode ec = U_ZERO_ERROR;
- if (NULL == tzid)
- {
+ if (NULL == tzid) {
ERR("tzid is NULL");
return false;
}
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;
}
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;
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 ? '+' : '-',
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();
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;
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);
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);
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);
}
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);
}
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);
{
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)",
}
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);
UCalendar *ucal;
UErrorCode status = U_ZERO_ERROR;
- if (tzid == NULL)
- {
+ if (NULL == tzid) {
DBG("tzid is NULL so set gmt");
tzid = CAL_TZID_GMT;
}
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);
}
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;
}
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);
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;
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)) {
return status;
}
- switch (today->type)
- {
+ switch (today->type) {
case CALENDAR_TIME_UTIME:
break;
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;
}
UCalendarDateFields unit = UCAL_DATE;
- switch (freq)
- {
+ switch (freq) {
case CALENDAR_RECURRENCE_YEARLY:
DBG("CALENDAR_RECURRENCE_YEARLY:");
unit = UCAL_YEAR;
}
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);
{
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/"));
}
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);
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;
#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;
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,
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;
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);
}
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);
DBG("Before [%s]", p);
while ('\0' != *p) {
if ('\r' == *p && '\n' == *(p + 1)) break;
- switch (*p)
- {
+ switch (*p) {
case '\n':
*q = '\\';
*(q +1) = 'n';
{
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;
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");
}
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;
// 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;
}
return;
}
length = g_strv_length(t);
- for (i = 0; i < length; i++)
- {
+ for (i = 0; i < length; i++) {
if (*t[i] == '\0')
continue;
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];
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);
}
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);
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);
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);
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);
break;
}
char *sensitivity = NULL;
- switch (value)
- {
+ switch (value) {
case CALENDAR_SENSITIVITY_PUBLIC:
sensitivity = "PUBLIC";
break;
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);
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);
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;
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);
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");
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;
{
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);
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;
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);
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);
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);
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);
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);
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);
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;
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);
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;
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);
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);
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);
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);
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);
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;
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;
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);
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;
}
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;
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);
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);
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);
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);
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);
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;
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);
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;
char *q = p;
while ('\0' != *p) {
if ('\\' == *p && *(p +1)) {
- switch (*(p +1))
- {
+ switch (*(p +1)) {
case '\\':
*q = '\\';
p++;
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':
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,
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);
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);
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);
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);
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);
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);
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);
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;
case VCAL_VER_2:
default:
- switch (original_priority)
- {
+ switch (original_priority) {
case 1 ... 4:
modified_priority = CALENDAR_TODO_PRIORITY_HIGH;
break;
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);
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;
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);
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);
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;
default:
has_by = true;
while (*(t[i] +j)) {
- switch (*(t[i] +j))
- {
+ switch (*(t[i] +j)) {
case '+':
exit_loop = true;
sign = 1;
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);
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;
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);
}
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);
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);
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);
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);
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);
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);
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");
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);
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);
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);
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;
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);
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);
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);
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);
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);
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);
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);
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])));
}
}
- if (bmutex == true)
- {
+ if (bmutex == true) {
cal_uri_property_flag = true;
cal_mutex_unlock(CAL_MUTEX_PROPERTY_HASH);
}
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);
}
{
#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;
}
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:
}
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
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;
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;
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;
}
while (cursor) {
value_data = (cal_search_value_s *)cursor->data;
- if (value_data == NULL) {
+ if (NULL == value_data) {
cursor = g_slist_next(cursor);
continue;
}
return false;
}
- while(1) {
+ while (1) {
if (find->write_list[i] == -1)
break;
if (calendarbook_id == find->write_list[i]) {
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:
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);
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);
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");
}
if (ids)
- {
*ids = _ids;
- }
else
- {
CAL_FREE(_ids);
- }
- if (count) *count = _count;
+
+ if (count)
+ *count = _count;
cal_db_util_end_trans(true);
return ret;
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;
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;
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;
}
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;
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");
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;
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;
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;
}
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;
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;
// 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);
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;
}
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;
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));
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);
}
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;
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",
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",
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);
// 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);
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);
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;
__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;
*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;",
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);
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) {
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++;
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;
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;
}
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);
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;
}
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);
_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;
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) {
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;
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));
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));
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));
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));
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));
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));
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)) {
_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;
break;
}
- if (0 < event->original_event_id)
- {
+ if (0 < event->original_event_id) {
DBG("return freq for exception event");
event->freq = exception_freq;
}
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;
}
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);
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;
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;
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);
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);
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);
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);
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;
}
}
//cal_record_set_int(record, _calendar_book.id,index);
if (id)
- {
*id = index;
- }
cal_db_util_notify(CAL_NOTI_TYPE_CALENDAR);
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:
}
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)
{
}
}
- 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);
}
calendar->index = id;
- if (calendar->common.properties_flags != NULL) {
+ if (calendar->common.properties_flags) {
return _cal_db_calendar_update_projection(record);
}
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) {
}
}
i++;
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+ } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
if (ids) {
*ids = id;
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;
}
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);
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;
}
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;
}
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,
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;
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;
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);
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);
}
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,
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,
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;
}
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);
}
//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);
}
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);
}
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
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)
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;
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, ")");
// 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);
}
// 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);
}
}
// 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;
}
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;
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;
}
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);
}
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;
}
}
}
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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);
}
}
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);
}
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;
}
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;
}
}
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;
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;
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, ")");
// 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;
}
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;
}
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);
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,
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,
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;
}
}
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) {
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) {
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++);
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
event = (cal_event_s*)(record);
- switch (property)
- {
+ switch (property) {
case CAL_PROPERTY_EVENT_ID:
event->index = sqlite3_column_int(stmt, *stmt_count);
break;
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);
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);
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);
}
}
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;
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);
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)
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)
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)
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)
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)
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);
}
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;
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);
}
}
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",
//DBG("(%lld)", start_utime);
}
- else
- {
+ else {
//DBG("ALLDAY instance");
snprintf(datetime, sizeof(datetime),
"%s", patterns1[i]);
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;
}
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);
}
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);
}
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);
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);
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;
}
}
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);
// 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);
}
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;
}
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);
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);
que->projection, que->projection_count,
record);
}
- else
- {
+ else {
_cal_db_extended_get_stmt(stmt,record);
}
*out_list = NULL;
calendar_record_destroy(record, true);
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
}
}
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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);
}
}
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);
}
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;
}
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;
}
}
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;
}
}
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);
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;
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);
// 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;
}
*out_count = count;
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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;
{
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);
}
}
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);
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;
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, ")");
// 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);
}
// 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);
}
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;
}
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);
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;
}
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);
}
*out_list = NULL;
calendar_record_destroy(record, true);
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
}
}
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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;
}
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;
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, ")");
// 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;
}
if (out_count) *out_count = count;
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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;
}
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
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;
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);
}
}
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);
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;
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, ")");
// 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);
}
// 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);
}
}
// 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;
}
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);
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;
}
*out_list = NULL;
calendar_record_destroy(record, true);
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
}
}
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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;
}
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;
}
}
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, ")");
// 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;
}
if (out_count) *out_count = count;
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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;
}
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
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;
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);
}
}
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);
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;
}
}
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, ")");
// 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);
}
// 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);
}
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;
}
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);
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);
que->projection, que->projection_count,
record);
}
- else
- {
+ else {
_cal_db_instance_normal_get_stmt(stmt,record);
}
*out_list = NULL;
calendar_record_destroy(record, true);
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
}
}
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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;
}
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;
}
}
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, ")");
// 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;
}
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;
}
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;
}
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;
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;
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);
}
}
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);
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;
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, ")");
// 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);
}
// 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);
}
}
// 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;
}
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);
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;
}
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);
}
*out_list = NULL;
calendar_record_destroy(record, true);
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
}
}
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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;
}
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;
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, ")");
// 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;
}
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;
}
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;
}
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;
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;
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);
}
}
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");
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, ")");
// 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);
}
// 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);
}
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;
}
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);
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;
}
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);
}
*out_list = NULL;
calendar_record_destroy(record, true);
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
}
}
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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;
}
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);
}
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, ")");
// 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;
}
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;
}
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;
}
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);
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);
}
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);
}
}
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;
}
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);
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)
{
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;
sqlite3_finalize(stmt);
//cal_record_set_int(record, _calendar_timezone.id,index);
- if (id)
- {
+ if (id) {
*id = index;
}
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;
}
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;
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);
}
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);
}
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 "
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);
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;
}
}
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)");
// 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);
}
}
// 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;
}
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);
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);
_cal_db_timezone_get_projection_stmt(stmt,
que->projection, que->projection_count,
record);
- }
- else
- {
+ } else {
_cal_db_timezone_get_stmt(stmt,record);
}
*out_list = NULL;
calendar_record_destroy(record, true);
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
}
}
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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);
}
}
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);
}
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;
}
{
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;
}
}
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;
}
}
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);
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;
}
}
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)");
// 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;
}
*out_count = count;
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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;
{
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);
}
}
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);
}
}
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;
}
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,
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,
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");
}
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;
}
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);
}
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);
}
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,
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,
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 "
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:
DBG("attendee, alarm and rrule will be deleted by trigger after sync clean");
}
- else
- {
+ else {
cal_db_util_get_next_ver();
DBG("delete event");
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;
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,
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,
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) {
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);
}
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);
}
}
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;
}
}
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, ")");
// 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);
}
// 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);
}
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;
}
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;
}
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);
}
*out_list = NULL;
calendar_record_destroy(record, true);
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
}
}
- if (bind_text)
- {
+ if (bind_text) {
g_slist_free_full(bind_text, free);
bind_text = NULL;
}
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);
}
}
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);
}
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;
}
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;
}
}
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;
}
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;
}
}
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;
}
}
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, ")");
// 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;
}
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;
}
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) {
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) {
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);
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,
todo = (cal_todo_s*)(record);
- switch (property)
- {
+ switch (property) {
case CAL_PROPERTY_TODO_ID:
todo->index = sqlite3_column_int(stmt, *stmt_count);
break;
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);
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);
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);
}
}
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;
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)
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)
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)
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)
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)
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;
}
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);
}
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);
}
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");
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;
}
// 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
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,
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=?",
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
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,
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=?",
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;
}
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;
}
}
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, ")");
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;
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;
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;
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;
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;
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;
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;
}
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);
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;
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));
}
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
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];
}
}
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];
}
}
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];
}
}
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;
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);
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;
{
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;
{
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;
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;
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};
}
_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
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) {
{
retry = false;
}
- } while(retry);
+ } while (retry);
if (SQLITE_OK != ret)
{
retry = false;
}
}
- else
+ else {
if (result) *result = sqlite3_column_int(stmt, 0);
+ }
} while(retry);
sqlite3_finalize(stmt);
{
retry = false;
}
- } while(retry);
+ } while (retry);
return stmt;
}
{
retry = false;
}
- } while(retry);
+ } while (retry);
switch (ret)
{
#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;
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;
}
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;
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;
}
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;
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;
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;
}
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;
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;
}
// 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);
_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));
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)
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",
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));
}
// 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;
}
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 "
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;
}
-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;
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");
{
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.
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;
}
{
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,
// don't use mutex.
g_cond_signal(&_cal_server_contacts_sync_cond);
-
- return;
}
+
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;
}
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;
}
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;
}
_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).
*/
/* ----------------------- 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.
*/
/* ----------------------- 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.
*/
old_version = 102;
}
- if (old_version == 102)
- {
+ if (old_version == 102) {
/* ----------------------- start modified 2014/10/24
* added field is_alldy on schedule_table
*/
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);
}
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);