, "Invalid argument is used. The event's recordId is not equal to eventInstance's original event ID.");
SysTryReturnResult(NID_SCL, CheckEventExistance(event.GetRecordId()), E_OBJ_NOT_FOUND, "The specified event is not found.");
- calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle();
+ calendar_record_h eventHandle = null;
+ errorCode = calendar_record_clone(_CalEventImpl::GetInstance(event)->GetRecordHandle(), &eventHandle);
+ SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+ _CalendarRecord eventRecord(eventHandle);
int baseEventId = _INVALID_EVENT_DB_ID;
errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId);
+ calendar_record_h baseEventHandle = null;
+ if (baseEventId == _INVALID_EVENT_DB_ID)
+ {
+ errorCode = calendar_db_get_record(_calendar_event._uri, eventInstance.GetOriginalEventId(), &baseEventHandle);
+ }
+ else
+ {
+ errorCode = calendar_db_get_record(_calendar_event._uri, baseEventId, &baseEventHandle);
+ }
+ SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.");
+ SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The base event is not found.");
+ _CalendarRecord baseEventRecord(baseEventHandle);
+
+ int tmpIntValue = 0;
+ errorCode = calendar_record_get_int(baseEventHandle, _calendar_event.freq, &tmpIntValue);
+ errorCode = calendar_record_set_int(eventHandle, _calendar_event.freq, tmpIntValue);
+ errorCode = calendar_record_get_int(baseEventHandle, _calendar_event.range_type, &tmpIntValue);
+ errorCode = calendar_record_set_int(eventHandle, _calendar_event.range_type, tmpIntValue);
+ errorCode = calendar_record_get_int(baseEventHandle, _calendar_event.count, &tmpIntValue);
+ errorCode = calendar_record_set_int(eventHandle, _calendar_event.count, tmpIntValue);
+ errorCode = calendar_record_get_int(baseEventHandle, _calendar_event.interval, &tmpIntValue);
+ errorCode = calendar_record_set_int(eventHandle, _calendar_event.interval, tmpIntValue);
+ errorCode = calendar_record_get_int(baseEventHandle, _calendar_event.wkst, &tmpIntValue);
+ errorCode = calendar_record_set_int(eventHandle, _calendar_event.wkst, tmpIntValue);
+
+ calendar_time_s tmpTimeValue;
+ errorCode = calendar_record_get_caltime(baseEventHandle, _calendar_event.until_time, &tmpTimeValue);
+ bool tmpIsAllDay = 0;
+ calendar_time_s tmpStartTimeValue;
+ DateTime convertedTime;
+ errorCode = calendar_record_get_caltime(eventHandle, _calendar_event.start_time, &tmpStartTimeValue);
+
+ if (tmpTimeValue.type != tmpStartTimeValue.type)
+ {
+ if (tmpStartTimeValue.type == CALENDAR_TIME_UTIME)
+ {
+ convertedTime.SetValue(tmpTimeValue.time.date.year, tmpTimeValue.time.date.month, tmpTimeValue.time.date.mday);
+ tmpTimeValue.type = CALENDAR_TIME_UTIME;
+ tmpTimeValue.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(convertedTime);
+ }
+ else
+ {
+ convertedTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(tmpTimeValue.time.utime);
+ tmpTimeValue.type = CALENDAR_TIME_LOCALTIME;
+ tmpTimeValue.time.date.year = convertedTime.GetYear();
+ tmpTimeValue.time.date.month = convertedTime.GetMonth();
+ tmpTimeValue.time.date.mday = convertedTime.GetDay();
+ }
+ }
+ errorCode = calendar_record_set_caltime(eventHandle, _calendar_event.until_time, tmpTimeValue);
+
+ char* tmpStrValue = null;
+ errorCode = calendar_record_get_str_p(baseEventHandle, _calendar_event.byday, &tmpStrValue);
+ errorCode = calendar_record_set_str(eventHandle, _calendar_event.byday, tmpStrValue);
+ errorCode = calendar_record_get_str_p(baseEventHandle, _calendar_event.bymonthday, &tmpStrValue);
+ errorCode = calendar_record_set_str(eventHandle, _calendar_event.bymonthday, tmpStrValue);
+ errorCode = calendar_record_get_str_p(baseEventHandle, _calendar_event.bymonth, &tmpStrValue);
+ errorCode = calendar_record_set_str(eventHandle, _calendar_event.bymonth, tmpStrValue);
+ errorCode = calendar_record_get_str_p(baseEventHandle, _calendar_event.exdate, &tmpStrValue);
+ errorCode = calendar_record_set_str(eventHandle, _calendar_event.exdate, tmpStrValue);
+
if (baseEventId == _INVALID_EVENT_DB_ID)
{
errorCode = calendar_record_set_int(eventHandle, _calendar_event.original_event_id, eventInstance.GetOriginalEventId());
+
std::unique_ptr<char[]> pConvertedRecurrenceId(_StringConverter::CopyToCharArrayN(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(eventInstance.GetStartTime(), eventInstance.IsAllDayEvent())));
errorCode = calendar_record_set_str(eventHandle, _calendar_event.recurrence_id, pConvertedRecurrenceId.get());
errorCode = calendar_db_insert_record(eventHandle, &dbIndex);
SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
_RecordImpl::GetInstance(event)->SetRecordId(dbIndex);
-
- calendar_record_h tmpEventHandle = null;
- errorCode = calendar_db_get_record(_calendar_event._uri, dbIndex, &tmpEventHandle);
- SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
- _CalEventImpl::GetInstance(event)->SetRecordHandle(tmpEventHandle);
}
else
{
SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The base event of the event is not found.");
}
+ calendar_record_h tmpEventHandle = null;
+ errorCode = calendar_db_get_record(_calendar_event._uri, dbIndex, &tmpEventHandle);
+ SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+ _CalEventImpl::GetInstance(event)->SetRecordHandle(tmpEventHandle);
+
return E_SUCCESS;
}