diff options
author | Hosang Kim <hosang.kim@samsung.com> | 2013-04-05 13:55:53 +0900 |
---|---|---|
committer | Gerrit Code Review <gerrit2@kim11> | 2013-04-05 13:55:53 +0900 |
commit | 14141fbb4ad0eaa9d4a4cfcfe08f2efcc39dde8c (patch) | |
tree | d9ad2efbbe7d90f9c785e931ee35b1ed7d662fea | |
parent | a698958a33f96c40c5176ca6fb533bbf0b31b71c (diff) | |
parent | 3c1fab2f1f559a3b7429faef5f047d138eed0de4 (diff) | |
download | social-14141fbb4ad0eaa9d4a4cfcfe08f2efcc39dde8c.tar.gz social-14141fbb4ad0eaa9d4a4cfcfe08f2efcc39dde8c.tar.bz2 social-14141fbb4ad0eaa9d4a4cfcfe08f2efcc39dde8c.zip |
Merge "Fixed update instance" into tizen_2.1
-rw-r--r-- | src/FScl_CalendarbookImpl.cpp | 77 |
1 files changed, 71 insertions, 6 deletions
diff --git a/src/FScl_CalendarbookImpl.cpp b/src/FScl_CalendarbookImpl.cpp index 3b8abdc..c1d9b2e 100644 --- a/src/FScl_CalendarbookImpl.cpp +++ b/src/FScl_CalendarbookImpl.cpp @@ -1344,14 +1344,79 @@ _CalendarbookImpl::UpdateEventInstance(const CalEventInstance& eventInstance, Ca , "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()); @@ -1359,11 +1424,6 @@ _CalendarbookImpl::UpdateEventInstance(const CalEventInstance& eventInstance, Ca 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 { @@ -1372,6 +1432,11 @@ _CalendarbookImpl::UpdateEventInstance(const CalEventInstance& eventInstance, Ca 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; } |