RETV_IF(NULL == handle, CALENDAR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == stream, CALENDAR_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == out_ids, CALENDAR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cal_dbus_object, CALENDAR_ERROR_IPC);
RETV_IF(NULL == out_record, CALENDAR_ERROR_INVALID_PARAMETER);
type = cal_view_get_type(view_uri);
- DBG("----------------------[%s]", view_uri);
RETV_IF(CAL_RECORD_TYPE_INVALID == type, CALENDAR_ERROR_INVALID_PARAMETER);
cal_record_plugin_cb_s *plugin_cb = cal_record_get_plugin_cb(type);
while (g_variant_iter_loop(iter_composite_pack, "(i&siv)",
&filter_type, &view_uri, &count_composite, &arg_composite)) {
- cal_composite_filter_s *c = calloc(1, sizeof(cal_composite_filter_s));
- if (NULL == c) {
+ cal_composite_filter_s *cf = calloc(1, sizeof(cal_composite_filter_s));
+ if (NULL == cf) {
ERR("calloc() Fail");
break;
}
- c->filter_type = CAL_FILTER_COMPOSITE;
- c->view_uri = cal_strdup(view_uri);
- c->properties = (cal_property_info_s *)cal_view_get_property_info(view_uri,
- &c->property_count);
+ cf->filter_type = CAL_FILTER_COMPOSITE;
+ cf->view_uri = cal_strdup(view_uri);
+ cf->properties = (cal_property_info_s *)cal_view_get_property_info(view_uri,
+ &cf->property_count);
int is_exit = 0;
if (0 == count_composite) {
filter->property_id = property_id;
filter->match = match;
_gvariant_to_attr_value(composite_filter_type, arg_attr_value, filter);
- c->filters = g_slist_append(c->filters, filter);
+ cf->filters = g_slist_append(cf->filters, filter);
}
if (1 == is_exit)
break;
if (NULL == composite)
- composite = c;
+ composite = cf;
else
- composite->filters = g_slist_append(composite->filters, c);
+ composite->filters = g_slist_append(composite->filters, cf);
}
*out_composite = composite;
{
pthread_mutex_lock(&cal_mutex_account);
- RET_IF(NULL == cal_account_h);
-
- account_unsubscribe_notification(cal_account_h);
- cal_account_h = NULL;
+ if (cal_account_h) {
+ account_unsubscribe_notification(cal_account_h);
+ cal_account_h = NULL;
+ }
pthread_mutex_unlock(&cal_mutex_account);
}
} else {
int y = 0, m = 0, d = 0;
int h = 0, n = 0, s = 0;
- sscanf(datetime, CAL_FORMAT_LOCAL_DATETIME, &y, &m, &d, &h, &n, &s);
-
- st.tm_year = y - 1900;
- st.tm_mon = m - 1;
- st.tm_mday = d;
- st.tm_hour = h;
- st.tm_min = n;
- st.tm_sec = s;
- *tt_alert = mktime(&st);
- DBG("datetime[%s] to %02d:%02d:%02d (%d)", datetime, h, n, s, *tt_alert);
+ if (datetime) {
+ sscanf(datetime, CAL_FORMAT_LOCAL_DATETIME, &y, &m, &d, &h, &n, &s);
+
+ st.tm_year = y - 1900;
+ st.tm_mon = m - 1;
+ st.tm_mday = d;
+ st.tm_hour = h;
+ st.tm_min = n;
+ st.tm_sec = s;
+ *tt_alert = mktime(&st);
+ DBG("datetime[%s] to %02d:%02d:%02d (%d)", datetime, h, n, s, *tt_alert);
+ }
}
sqlite3_finalize(stmt);
return CALENDAR_ERROR_NONE;
ret = cal_dbus_utils_gvariant_to_ids(arg_ids, count, &ids);
ret = cal_db_replace_records(list, ids, count);
+ free(ids);
int version = 0;
version = cal_db_util_get_transaction_ver();
ret = cal_dbus_utils_gvariant_to_ids(arg_ids, count, &ids);
ret = cal_db_replace_vcalendars(stream, ids, count);
+ free(ids);
int version = 0;
version = cal_db_util_get_transaction_ver();
extern cal_db_plugin_cb_s cal_db_timezone_plugin_cb;
extern cal_db_plugin_cb_s cal_db_extended_plugin_cb;
-int cal_db_append_string(char **dst, char *src)
+int cal_db_append_string(char **dst, const char *src)
{
RETV_IF(NULL == dst, CALENDAR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == src, CALENDAR_ERROR_INVALID_PARAMETER);
}
return CALENDAR_ERROR_NONE;
}
+
int len_dst = strlen(*dst);
char *tmp = *dst;
tmp = (char *)realloc(tmp, len_dst + len_src + 2);
return CALENDAR_ERROR_OUT_OF_MEMORY;
}
*dst = tmp;
- strcat(*dst, " ");
- strcat(*dst, src);
+ snprintf(*dst + len_dst, len_src + 2, " %s", src);
+
return CALENDAR_ERROR_NONE;
}
int cal_db_get_changes_by_version(const char* view_uri, int calendar_book_id, int calendar_db_version, calendar_list_h* record_list, int *current_calendar_db_version);
int cal_db_get_changes_exception_by_version(const char* view_uri, int original_event_id, int calendar_db_version, calendar_list_h* record_list);
-int cal_db_append_string(char **dst, char *src);
+int cal_db_append_string(char **dst, const char *src);
cal_db_plugin_cb_s* _cal_db_get_plugin(cal_record_type_e type);
#endif /* __CAL_DB_H__ */
int len_t = g_strv_length(t);
+ char *field = NULL;
int len_field = strlen(old_field);
- char *new = NULL;
- new = calloc(len_field + (len_t * 8) + 1, sizeof(char)); /* add (len_t * 8) for YYYYMMDD -> YYYYMMDDTHHMMSSZ */
- if (NULL == new) {
+ len_field += (len_t * 8) + 1; /* add (len_t * 8) for YYYYMMDD -> YYYYMMDDTHHMMSSZ */
+
+ field = calloc(len_field, sizeof(char)); /* add (len_t * 8) for YYYYMMDD -> YYYYMMDDTHHMMSSZ */
+ if (NULL == field) {
ERR("calloc() Fail");
g_strfreev(t);
return CALENDAR_ERROR_OUT_OF_MEMORY;
struct tm tm = {0};
time_t tt = 0;
+ int len = 0;
int i;
for (i = 0; i < len_t; i++) {
int y = 0, m = 0, d = 0;
}
break;
}
- strcat(new, buf);
+ len += snprintf(field + len, len_field -len, "%s", buf);
+ DBG("[%s]", field);
}
g_strfreev(t);
if (new_field)
- *new_field = new;
+ *new_field = field;
else
- free(new);
+ free(field);
+
return CALENDAR_ERROR_NONE;
}
if (CALENDAR_ERROR_NONE != ret)
continue;
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);
+ 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);
} else {
int *exception_ids = NULL;
int exception_len = 0;
- ret = _cal_db_event_exdate_insert_normal(event_id, original_exdate, record_exdate, &exception_ids, &exception_len);
+ ret = _cal_db_event_exdate_insert_normal(event_id, original_exdate,
+ record_exdate, &exception_ids, &exception_len);
WARN_IF(CALENDAR_ERROR_NONE != ret, "%s->%s", original_exdate, record_exdate);
ret = _cal_db_event_delete_exception(exception_ids, exception_len);
WARN_IF(CALENDAR_ERROR_NONE != ret, "_cal_db_event_delete_record() Fail");
return CALENDAR_ERROR_NONE;
}
-static int _cal_db_event_exdate_insert_normal(int event_id, const char* original_exdate, const char* exdate, int **exception_ids, int *exception_len)
+static int _cal_db_event_exdate_insert_normal(int event_id, const char* original_exdate,
+ const char* exdate, int **exception_ids, int *exception_len)
{
int ret = CALENDAR_ERROR_NONE;
gchar **patterns1 = NULL;
_rrule->until.time.utime = sqlite3_column_int64(stmt, index++);
temp = sqlite3_column_text(stmt, index++);
- if (CALENDAR_TIME_LOCALTIME == _rrule->until.type) {
- sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME,
- &_rrule->until.time.date.year,
- &_rrule->until.time.date.month,
- &_rrule->until.time.date.mday,
- &_rrule->until.time.date.hour,
- &_rrule->until.time.date.minute,
- &_rrule->until.time.date.second);
+ if (temp) {
+ if (CALENDAR_TIME_LOCALTIME == _rrule->until.type) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME,
+ &_rrule->until.time.date.year,
+ &_rrule->until.time.date.month,
+ &_rrule->until.time.date.mday,
+ &_rrule->until.time.date.hour,
+ &_rrule->until.time.date.minute,
+ &_rrule->until.time.date.second);
+ }
}
_rrule->count = sqlite3_column_int(stmt, index++);