From 7388ea7f5f12fcfe3056170b11442b81c584da95 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Thu, 16 May 2013 21:19:05 +0900 Subject: [PATCH] Add error handling codes Change-Id: Id77d2e1b730d6359653ce96eb01fd8447ba93795 Signed-off-by: Hosang Kim --- src/FScl_CalEventImpl.cpp | 294 +++++++++--------- src/FScl_CalTodoImpl.cpp | 100 +++--- src/FScl_CalendarImpl.cpp | 38 +-- src/FScl_CalendarbookImpl.cpp | 425 ++++++++++++++------------ src/FScl_CalendarbookRecordRetrivalThread.cpp | 4 +- src/FScl_CalendarbookUtil.cpp | 64 ++-- 6 files changed, 465 insertions(+), 460 deletions(-) diff --git a/src/FScl_CalEventImpl.cpp b/src/FScl_CalEventImpl.cpp index c102d63..6f7b101 100644 --- a/src/FScl_CalEventImpl.cpp +++ b/src/FScl_CalEventImpl.cpp @@ -120,14 +120,14 @@ _CalEventImpl::_CalEventImpl(void) __eventRecord.ResetHandle(eventHandle); - errorCode = calendar_record_set_caltime(eventHandle, _calendar_event.start_time, startCalendarTime); - errorCode = calendar_record_set_caltime(eventHandle, _calendar_event.end_time, endCalendarTime); + calendar_record_set_caltime(eventHandle, _calendar_event.start_time, startCalendarTime); + calendar_record_set_caltime(eventHandle, _calendar_event.end_time, endCalendarTime); // default value - errorCode = calendar_record_set_int(eventHandle, _calendar_event.event_status, CALENDAR_EVENT_STATUS_NONE); - errorCode = calendar_record_set_int(eventHandle, _calendar_event.busy_status, CALENDAR_EVENT_BUSY_STATUS_FREE); - errorCode = calendar_record_set_int(eventHandle, _calendar_event.priority, CALENDAR_EVENT_PRIORITY_NORMAL); - errorCode = calendar_record_set_int(eventHandle, _calendar_event.sensitivity, CALENDAR_SENSITIVITY_PUBLIC); + calendar_record_set_int(eventHandle, _calendar_event.event_status, CALENDAR_EVENT_STATUS_NONE); + calendar_record_set_int(eventHandle, _calendar_event.busy_status, CALENDAR_EVENT_BUSY_STATUS_FREE); + calendar_record_set_int(eventHandle, _calendar_event.priority, CALENDAR_EVENT_PRIORITY_NORMAL); + calendar_record_set_int(eventHandle, _calendar_event.sensitivity, CALENDAR_SENSITIVITY_PUBLIC); r = __reminderList.Construct(); SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); @@ -155,8 +155,7 @@ _CalEventImpl::_CalEventImpl(const _CalEventImpl& rhs) _CalEventImpl::~_CalEventImpl(void) { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_destroy(__eventRecord.ReleaseHandle(), true); + calendar_record_destroy(__eventRecord.ReleaseHandle(), true); __reminderList.RemoveAll(true); @@ -197,10 +196,9 @@ _CalEventImpl::IsInstance(void) const bool _CalEventImpl::IsRecurring(void) const { - int errorCode = CALENDAR_ERROR_NONE; int recurrenceFreq = CALENDAR_RECURRENCE_NONE; - errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.freq, &recurrenceFreq); + calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.freq, &recurrenceFreq); if (recurrenceFreq == CALENDAR_RECURRENCE_NONE) { @@ -219,10 +217,9 @@ _CalEventImpl::GetOriginalCalEventId(void) const bool _CalEventImpl::IsAllDayEvent(void) const { - int errorCode = CALENDAR_ERROR_NONE; calendar_time_s startCalendarTime; - errorCode = calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime); + calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime); if (startCalendarTime.type == CALENDAR_TIME_UTIME) { return false; @@ -247,8 +244,8 @@ _CalEventImpl::SetAllDayEvent(bool isAllDayEvent) bool isChanged = false; - errorCode = calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime); - errorCode = calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, &endCalendarTime); + calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime); + calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, &endCalendarTime); if (isAllDayEvent && startCalendarTime.type == CALENDAR_TIME_UTIME) { @@ -264,8 +261,8 @@ _CalEventImpl::SetAllDayEvent(bool isAllDayEvent) tmpEndCalendarTime.time.date.month = tmpEndTime.GetMonth(); tmpEndCalendarTime.time.date.mday = tmpEndTime.GetDay(); - errorCode = calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, tmpStartCalendarTime); - errorCode = calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, tmpEndCalendarTime); + calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, tmpStartCalendarTime); + calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, tmpEndCalendarTime); isChanged = true; } @@ -281,8 +278,8 @@ _CalEventImpl::SetAllDayEvent(bool isAllDayEvent) tmpEndTime.SetValue(endCalendarTime.time.date.year, endCalendarTime.time.date.month, endCalendarTime.time.date.mday); tmpEndCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(tmpEndTime); - errorCode = calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, tmpStartCalendarTime); - errorCode = calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, tmpEndCalendarTime); + calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, tmpStartCalendarTime); + calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, tmpEndCalendarTime); isChanged = true; } @@ -290,14 +287,14 @@ _CalEventImpl::SetAllDayEvent(bool isAllDayEvent) if (IsRecurring()) { int rangeType = CALENDAR_RANGE_NONE; - errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.range_type, &rangeType); + calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.range_type, &rangeType); if (rangeType == CALENDAR_RANGE_UNTIL) { calendar_time_s untilCalendarTime; calendar_time_s tmpUntilCalendarTime; - errorCode = calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.until_time, &untilCalendarTime); + calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.until_time, &untilCalendarTime); if (isAllDayEvent && untilCalendarTime.type == CALENDAR_TIME_UTIME) { tmpUntilCalendarTime.type = CALENDAR_TIME_LOCALTIME; @@ -306,7 +303,7 @@ _CalEventImpl::SetAllDayEvent(bool isAllDayEvent) tmpUntilCalendarTime.time.date.month = tmpUntilTime.GetMonth(); tmpUntilCalendarTime.time.date.mday = tmpUntilTime.GetDay(); - errorCode = calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.until_time, tmpUntilCalendarTime); + calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.until_time, tmpUntilCalendarTime); } else if (!isAllDayEvent && untilCalendarTime.type == CALENDAR_TIME_LOCALTIME) { @@ -315,7 +312,7 @@ _CalEventImpl::SetAllDayEvent(bool isAllDayEvent) tmpUntilTime.SetValue(untilCalendarTime.time.date.year, untilCalendarTime.time.date.month, untilCalendarTime.time.date.mday); tmpUntilCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(tmpUntilTime); - errorCode = calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.until_time, tmpUntilCalendarTime); + calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.until_time, tmpUntilCalendarTime); } } @@ -328,6 +325,7 @@ _CalEventImpl::SetAllDayEvent(bool isAllDayEvent) std::unique_ptr pExDates(_StringConverter::CopyToCharArrayN(ConvertRecurrenceToRRuleExDateString(*__pRecurrence.get(), isAllDayEvent))); errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.exdate, pExDates.get()); + SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } } } @@ -337,9 +335,8 @@ _CalEventImpl::GetUIDN(void) const { ClearLastResult(); - int errorCode = CALENDAR_ERROR_NONE; char* pStrUid = null; - errorCode = calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.uid, &pStrUid); + calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.uid, &pStrUid); if (pStrUid == null || strlen(pStrUid) == 0) { @@ -363,10 +360,12 @@ _CalEventImpl::SetUID(const ByteBuffer* pUid) SysTryReturn(NID_SCL, pConvertedUidArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.uid, pConvertedUidArray.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); } else { errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.uid, null); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); } return E_SUCCESS; @@ -375,9 +374,8 @@ _CalEventImpl::SetUID(const ByteBuffer* pUid) Tizen::Base::String _CalEventImpl::GetUid(void) const { - int errorCode = CALENDAR_ERROR_NONE; char* pStrUid = null; - errorCode = calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.uid, &pStrUid); + calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.uid, &pStrUid); return String(pStrUid); } @@ -391,17 +389,17 @@ _CalEventImpl::SetUid(const Tizen::Base::String& uid) SysTryReturnVoidResult(NID_SCL, pStrUid != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.uid, pStrUid.get()); + SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } EventStatus _CalEventImpl::GetStatus(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcEventStatus = CALENDAR_EVENT_STATUS_NONE; EventStatus eventStatus = EVENT_STATUS_NONE; - errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.event_status, &srcEventStatus); + calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.event_status, &srcEventStatus); switch (srcEventStatus) { @@ -428,19 +426,17 @@ _CalEventImpl::GetStatus(void) const void _CalEventImpl::SetStatus(EventStatus status) { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.event_status, _CalendarbookUtil::ConvertEventStatusToCSEventStatus(status)); + calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.event_status, _CalendarbookUtil::ConvertEventStatusToCSEventStatus(status)); } BusyStatus _CalEventImpl::GetBusyStatus(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcEventBusyStatus = CALENDAR_EVENT_BUSY_STATUS_FREE; BusyStatus busyStatus = BUSY_STATUS_FREE; - errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.busy_status, &srcEventBusyStatus); + calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.busy_status, &srcEventBusyStatus); switch (srcEventBusyStatus) { @@ -468,19 +464,17 @@ _CalEventImpl::GetBusyStatus(void) const void _CalEventImpl::SetBusyStatus(BusyStatus busyStatus) { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.busy_status, _CalendarbookUtil::ConvertBusyStatusToCSEventBusyStatus(busyStatus)); + calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.busy_status, _CalendarbookUtil::ConvertBusyStatusToCSEventBusyStatus(busyStatus)); } EventPriority _CalEventImpl::GetPriority(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcPriority = CALENDAR_EVENT_PRIORITY_LOW; EventPriority priority = EVENT_PRIORITY_NORMAL; - errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.priority, &srcPriority); + calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.priority, &srcPriority); switch (srcPriority) { @@ -506,8 +500,7 @@ _CalEventImpl::GetPriority(void) const void _CalEventImpl::SetPriority(EventPriority priority) { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.priority, _CalendarbookUtil::ConvertEventPriorityToCSEventPriority(priority)); + calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.priority, _CalendarbookUtil::ConvertEventPriorityToCSEventPriority(priority)); } result @@ -585,13 +578,17 @@ _CalEventImpl::AddAttendee(const Attendee& attendee) SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_set_str(attendeeHandle, _calendar_attendee.name, pConvertedName.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_set_str(attendeeHandle, _calendar_attendee.email, pConvertedEmail.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_set_str(attendeeHandle, _calendar_attendee.number, pConvertedPhoneNumber.get()); - errorCode = calendar_record_set_int(attendeeHandle, _calendar_attendee.status, convertedStatus); - errorCode = calendar_record_set_int(attendeeHandle, _calendar_attendee.role, convertedRole); - errorCode = calendar_record_set_int(attendeeHandle, _calendar_attendee.person_id, attendee.GetPersonId()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); + calendar_record_set_int(attendeeHandle, _calendar_attendee.status, convertedStatus); + calendar_record_set_int(attendeeHandle, _calendar_attendee.role, convertedRole); + calendar_record_set_int(attendeeHandle, _calendar_attendee.person_id, attendee.GetPersonId()); errorCode = calendar_record_add_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, attendeeHandle); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); return E_SUCCESS; } @@ -599,7 +596,6 @@ _CalEventImpl::AddAttendee(const Attendee& attendee) result _CalEventImpl::RemoveAttendee(const Attendee& attendee) { - int errorCode = CALENDAR_ERROR_NONE; int index = _INVALID_ATTENDEE_INDEX; std::unique_ptr pConvertedEmail(_StringConverter::CopyToCharArrayN(attendee.GetEmail())); @@ -609,8 +605,8 @@ _CalEventImpl::RemoveAttendee(const Attendee& attendee) SysTryReturnResult(NID_SCL, index != _INVALID_ATTENDEE_INDEX, E_OBJ_NOT_FOUND, "The specified attendee does not exist.") calendar_record_h tmpAttendeeHandle = null; - errorCode = calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, index, &tmpAttendeeHandle); - errorCode = calendar_record_remove_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, tmpAttendeeHandle); + calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, index, &tmpAttendeeHandle); + calendar_record_remove_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, tmpAttendeeHandle); return E_SUCCESS; } @@ -620,15 +616,13 @@ _CalEventImpl::GetAllAttendeesN(void) const { ClearLastResult(); - int errorCode = CALENDAR_ERROR_NONE; - std::unique_ptr pList(new (std::nothrow) ArrayList()); SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); result r = pList->Construct(); SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); unsigned int attendeeCount = 0; - errorCode = calendar_record_get_child_record_count(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, &attendeeCount); + calendar_record_get_child_record_count(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, &attendeeCount); for (int i = 0; i < attendeeCount; i++) { @@ -642,13 +636,13 @@ _CalEventImpl::GetAllAttendeesN(void) const AttendeeStatus attendeeStatus = ATTENDEE_STATUS_NONE; AttendeeRole attendeeRole = ATTENDEE_ROLE_ATTENDEE; - errorCode = calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, i, &tmpAttendeeHandle); - errorCode = calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.email, &pTmpEmail); - errorCode = calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.name, &pTmpName); - errorCode = calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.number, &pTmpPhoneNumber); - errorCode = calendar_record_get_int(tmpAttendeeHandle, _calendar_attendee.status, &tmpStatus); - errorCode = calendar_record_get_int(tmpAttendeeHandle, _calendar_attendee.role, &tmpRole); - errorCode = calendar_record_get_int(tmpAttendeeHandle, _calendar_attendee.person_id, &tmpPersonId); + calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, i, &tmpAttendeeHandle); + calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.email, &pTmpEmail); + calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.name, &pTmpName); + calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.number, &pTmpPhoneNumber); + calendar_record_get_int(tmpAttendeeHandle, _calendar_attendee.status, &tmpStatus); + calendar_record_get_int(tmpAttendeeHandle, _calendar_attendee.role, &tmpRole); + calendar_record_get_int(tmpAttendeeHandle, _calendar_attendee.person_id, &tmpPersonId); switch (tmpStatus) { @@ -725,15 +719,13 @@ _CalEventImpl::GetAllAttendeesN(void) const Tizen::Locales::TimeZone _CalEventImpl::GetTimeZone(void) const { - int errorCode = CALENDAR_ERROR_NONE; char* pTimeZoneId = null; TimeZone timeZone; - result r = E_SUCCESS; - errorCode = calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.start_tzid, &pTimeZoneId); + calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.start_tzid, &pTimeZoneId); if (pTimeZoneId != null && strlen(pTimeZoneId) > 0) { - r = TimeZone::GetTimeZone(pTimeZoneId, timeZone); + TimeZone::GetTimeZone(pTimeZoneId, timeZone); } return timeZone; @@ -748,7 +740,9 @@ _CalEventImpl::SetTimeZone(const Tizen::Locales::TimeZone& timeZone) SysTryReturnResult(NID_SCL, pConvertedTimeZoneId != null, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.start_tzid, pConvertedTimeZoneId.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.end_tzid, pConvertedTimeZoneId.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); return E_SUCCESS; } @@ -766,10 +760,9 @@ _CalEventImpl::GetRecurrenceId(void) const String _CalEventImpl::GetSubject(void) const { - int errorCode = CALENDAR_ERROR_NONE; char* pSubject = null; - errorCode = calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.summary, &pSubject); + calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.summary, &pSubject); return String(pSubject); } @@ -777,21 +770,19 @@ _CalEventImpl::GetSubject(void) const String _CalEventImpl::GetDescription(void) const { - int errorCode = CALENDAR_ERROR_NONE; char* pDescription = null; - errorCode = calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.description, &pDescription); + calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.description, &pDescription); return String(pDescription); } DateTime _CalEventImpl::GetStartTime(void) const { - int errorCode = CALENDAR_ERROR_NONE; calendar_time_s startCalendarTime; DateTime tmpStartTime; - errorCode = calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime); + calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime); if (startCalendarTime.type == CALENDAR_TIME_UTIME) { @@ -808,11 +799,10 @@ _CalEventImpl::GetStartTime(void) const DateTime _CalEventImpl::GetEndTime(void) const { - int errorCode = CALENDAR_ERROR_NONE; calendar_time_s endCalendarTime; DateTime tmpEndTime; - errorCode = calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, &endCalendarTime); + calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, &endCalendarTime); if (endCalendarTime.type == CALENDAR_TIME_UTIME) { @@ -829,10 +819,9 @@ _CalEventImpl::GetEndTime(void) const String _CalEventImpl::GetLocation(void) const { - int errorCode = CALENDAR_ERROR_NONE; char* pLocation = null; - errorCode = calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.location, &pLocation); + calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.location, &pLocation); return String(pLocation); } @@ -840,11 +829,9 @@ _CalEventImpl::GetLocation(void) const EventCategory _CalEventImpl::GetCategory(void) const { - - int errorCode = CALENDAR_ERROR_NONE; char* pCategories = null; - errorCode = calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.categories, &pCategories); + calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.categories, &pCategories); return _CalendarbookUtil::ConvertCSCategoriesToEventCategory(pCategories); } @@ -852,11 +839,10 @@ _CalEventImpl::GetCategory(void) const RecordSensitivity _CalEventImpl::GetSensitivity(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcSensitivity = CALENDAR_SENSITIVITY_PUBLIC; RecordSensitivity sensitivity = SENSITIVITY_PUBLIC; - errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.sensitivity, &srcSensitivity); + calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.sensitivity, &srcSensitivity); switch (srcSensitivity) { @@ -910,7 +896,6 @@ _CalEventImpl::GetRecurrence(void) const Recurrence* _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) const { - int errorCode = CALENDAR_ERROR_NONE; int srcFrequency = CALENDAR_RECURRENCE_NONE; calendar_time_s untilCalendarTime; int rangeType = CALENDAR_RANGE_NONE; @@ -931,27 +916,27 @@ _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) co std::unique_ptr pRecurrence(new (std::nothrow) Recurrence()); - errorCode = calendar_record_get_int(eventHandle, _calendar_event.freq, &srcFrequency); + calendar_record_get_int(eventHandle, _calendar_event.freq, &srcFrequency); if (srcFrequency == CALENDAR_RECURRENCE_NONE) { return null; } - errorCode = calendar_record_get_int(eventHandle, _calendar_event.range_type, &rangeType); - errorCode = calendar_record_get_int(eventHandle, _calendar_event.count, &count); - errorCode = calendar_record_get_int(eventHandle, _calendar_event.interval, &interval); - errorCode = calendar_record_get_caltime(eventHandle, _calendar_event.until_time, &untilCalendarTime); - errorCode = calendar_record_get_int(eventHandle, _calendar_event.wkst, &weekStart); + calendar_record_get_int(eventHandle, _calendar_event.range_type, &rangeType); + calendar_record_get_int(eventHandle, _calendar_event.count, &count); + calendar_record_get_int(eventHandle, _calendar_event.interval, &interval); + calendar_record_get_caltime(eventHandle, _calendar_event.until_time, &untilCalendarTime); + calendar_record_get_int(eventHandle, _calendar_event.wkst, &weekStart); - errorCode = calendar_record_get_str_p(eventHandle, _calendar_event.byday, &pByDay); - errorCode = calendar_record_get_str_p(eventHandle, _calendar_event.bymonthday, &pByMonthDay); + calendar_record_get_str_p(eventHandle, _calendar_event.byday, &pByDay); + calendar_record_get_str_p(eventHandle, _calendar_event.bymonthday, &pByMonthDay); if (pByMonthDay != null) { r = Integer::Parse(pByMonthDay, dayOfMonth); SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); } - errorCode = calendar_record_get_str_p(eventHandle, _calendar_event.bymonth, &pByMonth); + calendar_record_get_str_p(eventHandle, _calendar_event.bymonth, &pByMonth); if (pByMonth != null) { r = Integer::Parse(pByMonth, monthOfYear); @@ -969,7 +954,7 @@ _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) co dayOfWeek = ConvertRRuleByDayStringToDayOfWeek(pByDay); SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. byday = %s", pByDay); - r = pRecurrence->SetDayOfWeek(dayOfWeek); + pRecurrence->SetDayOfWeek(dayOfWeek); break; case CALENDAR_RECURRENCE_MONTHLY: @@ -980,20 +965,20 @@ _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) co if (dayOfMonth < 0) { int maxDaysOfMonth = _CalendarbookUtil::GetMaxDaysOfMonth(untilCalendarTime.time.date.year, monthOfYear); - r = pRecurrence->SetDayOfMonth(maxDaysOfMonth + dayOfMonth); + pRecurrence->SetDayOfMonth(maxDaysOfMonth + dayOfMonth); } else { - r = pRecurrence->SetDayOfMonth(dayOfMonth); + pRecurrence->SetDayOfMonth(dayOfMonth); } } else { - r = ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(pByDay, weekOfMonth, dayOfWeek); + ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(pByDay, weekOfMonth, dayOfWeek); SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. byday = %s", pByDay); - r = pRecurrence->SetWeekOfMonth(weekOfMonth); - r = pRecurrence->SetDayOfWeek(dayOfWeek); + pRecurrence->SetWeekOfMonth(weekOfMonth); + pRecurrence->SetDayOfWeek(dayOfWeek); } break; @@ -1005,11 +990,11 @@ _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) co if (dayOfMonth < 0) { int maxDaysOfMonth = _CalendarbookUtil::GetMaxDaysOfMonth(untilCalendarTime.time.date.year, monthOfYear); - r = pRecurrence->SetDayOfMonth(maxDaysOfMonth + dayOfMonth); + pRecurrence->SetDayOfMonth(maxDaysOfMonth + dayOfMonth); } else { - r = pRecurrence->SetDayOfMonth(dayOfMonth); + pRecurrence->SetDayOfMonth(dayOfMonth); } } else @@ -1017,10 +1002,10 @@ _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) co r = ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(pByDay, weekOfMonth, dayOfWeek); SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. byday = %s", pByDay); - r = pRecurrence->SetWeekOfMonth(weekOfMonth); - r = pRecurrence->SetDayOfWeek(dayOfWeek); + pRecurrence->SetWeekOfMonth(weekOfMonth); + pRecurrence->SetDayOfWeek(dayOfWeek); } - r = pRecurrence->SetMonthOfYear(monthOfYear); + pRecurrence->SetMonthOfYear(monthOfYear); break; default : @@ -1030,7 +1015,7 @@ _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) co if (rangeType == CALENDAR_RANGE_NONE) { - r = pRecurrence->SetUntil(&DateTime::GetMaxValue()); + pRecurrence->SetUntil(&DateTime::GetMaxValue()); } else if (rangeType == CALENDAR_RANGE_UNTIL) { @@ -1045,13 +1030,13 @@ _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) co until = _CalendarbookUtil::ConvertEpochTimeToDateTime(untilCalendarTime.time.utime); } - r = pRecurrence->SetUntil(&until); + pRecurrence->SetUntil(&until); } else { - r = pRecurrence->SetCounts(count); + pRecurrence->SetCounts(count); } - r = pRecurrence->SetInterval(interval); + pRecurrence->SetInterval(interval); switch (weekStart) { @@ -1065,9 +1050,9 @@ _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) co SysLogException(NID_SCL, E_INVALID_ARG, "Invalid argument is passed. week start = %d", weekStart); return null; } - r = pRecurrence->SetWeekStart(convertedWeekStart); + pRecurrence->SetWeekStart(convertedWeekStart); - errorCode = calendar_record_get_str_p(eventHandle, _calendar_event.exdate, &pExDates); + calendar_record_get_str_p(eventHandle, _calendar_event.exdate, &pExDates); if (pExDates != null && strlen(pExDates) != 0) { r = ConvertRRuleExDateStringToRecurrence(pExDates, *pRecurrence.get()); @@ -1080,11 +1065,10 @@ _CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) co DateTime _CalEventImpl::GetLastRevisedTime(void) const { - int errorCode = CALENDAR_ERROR_NONE; long long lastModifiedTime = 0; DateTime tmpLastRevisedTime; - errorCode = calendar_record_get_lli(__eventRecord.GetHandle(), _calendar_event.last_modified_time, &lastModifiedTime); + calendar_record_get_lli(__eventRecord.GetHandle(), _calendar_event.last_modified_time, &lastModifiedTime); tmpLastRevisedTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(lastModifiedTime); @@ -1105,6 +1089,7 @@ _CalEventImpl::SetSubject(const String& subject) int errorCode = CALENDAR_ERROR_NONE; errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.summary, pConvertedSubject.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); return E_SUCCESS; } @@ -1123,6 +1108,7 @@ _CalEventImpl::SetDescription(const String& description) int errorCode = CALENDAR_ERROR_NONE; errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.description, pConvertedDescription.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); return E_SUCCESS; } @@ -1141,6 +1127,7 @@ _CalEventImpl::SetLocation(const String& location) int errorCode = CALENDAR_ERROR_NONE; errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.location, pConvertedLocation.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); return E_SUCCESS; } @@ -1148,10 +1135,9 @@ _CalEventImpl::SetLocation(const String& location) result _CalEventImpl::SetStartAndEndTime(const DateTime& start, const DateTime& end) { - int errorCode = CALENDAR_ERROR_NONE; int recurrenceFrequency = 0; - errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.freq, &recurrenceFrequency); + calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.freq, &recurrenceFrequency); SysTryReturnResult(NID_SCL, recurrenceFrequency == CALENDAR_RECURRENCE_NONE, E_INVALID_CONDITION , "The recurrence date is already set. Cannot modify the start and end date/time."); @@ -1165,11 +1151,10 @@ _CalEventImpl::SetStartAndEndTime(const DateTime& start, const DateTime& end) result _CalEventImpl::SetStartAndEndTimeCommon(const DateTime& start, const DateTime& end) { - int errorCode = CALENDAR_ERROR_NONE; calendar_time_s startCalendarTime; calendar_time_s endCalendarTime; - errorCode = calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime); + calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime); if (startCalendarTime.type == CALENDAR_TIME_LOCALTIME) { @@ -1190,8 +1175,8 @@ _CalEventImpl::SetStartAndEndTimeCommon(const DateTime& start, const DateTime& e endCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(end); } - errorCode = calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, startCalendarTime); - errorCode = calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, endCalendarTime); + calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, startCalendarTime); + calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, endCalendarTime); return E_SUCCESS; } @@ -1216,13 +1201,13 @@ _CalEventImpl::SetCategory(EventCategory category) } errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.categories, pConvertedCategory.get()); + SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } void _CalEventImpl::SetSensitivity(RecordSensitivity sensitivity) { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.sensitivity, _CalendarbookUtil::ConvertSensitivityToCSSensitivity(sensitivity)); + calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.sensitivity, _CalendarbookUtil::ConvertSensitivityToCSSensitivity(sensitivity)); } result @@ -1231,10 +1216,8 @@ _CalEventImpl::SetCoordinates(double latitude, double longitude) SysTryReturnResult(NID_SCL, latitude >= _MIN_LATITUDE && latitude <= _MAX_LATITUDE, E_INVALID_ARG, "Invalid argument is used. The latitude is out of range."); SysTryReturnResult(NID_SCL, longitude >= _MIN_LONGITUDE && longitude <= _MAX_LONGITUDE, E_INVALID_ARG, "Invalid argument is used. The longitude is out of range."); - int errorCode = CALENDAR_ERROR_NONE; - - errorCode = calendar_record_set_double(__eventRecord.GetHandle(), _calendar_event.latitude, latitude); - errorCode = calendar_record_set_double(__eventRecord.GetHandle(), _calendar_event.longitude, longitude); + calendar_record_set_double(__eventRecord.GetHandle(), _calendar_event.latitude, latitude); + calendar_record_set_double(__eventRecord.GetHandle(), _calendar_event.longitude, longitude); return E_SUCCESS; } @@ -1242,10 +1225,8 @@ _CalEventImpl::SetCoordinates(double latitude, double longitude) void _CalEventImpl::GetCoordinates(double& latitude, double& longitude) const { - int errorCode = CALENDAR_ERROR_NONE; - - errorCode = calendar_record_get_double(__eventRecord.GetHandle(), _calendar_event.latitude, &latitude); - errorCode = calendar_record_get_double(__eventRecord.GetHandle(), _calendar_event.longitude, &longitude); + calendar_record_get_double(__eventRecord.GetHandle(), _calendar_event.latitude, &latitude); + calendar_record_get_double(__eventRecord.GetHandle(), _calendar_event.longitude, &longitude); } result @@ -1256,7 +1237,7 @@ _CalEventImpl::SetReminder(const Reminder* pReminder) unsigned int reminderCount = 0; calendar_record_h tmpAlarmHandle = null; - errorCode = calendar_record_get_child_record_count(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, &reminderCount); + calendar_record_get_child_record_count(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, &reminderCount); if (pReminder != null) { @@ -1283,14 +1264,15 @@ _CalEventImpl::SetReminder(const Reminder* pReminder) if (reminderCount > 0) { - errorCode = calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, 0, &tmpAlarmHandle); - errorCode = calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit); - errorCode = calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, pReminder->GetTimeOffset()); + calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, 0, &tmpAlarmHandle); + calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit); + calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, pReminder->GetTimeOffset()); std::unique_ptr pTmpAlarmTone(_StringConverter::CopyToCharArrayN(pReminder->GetSoundFile())); SysTryReturnResult(NID_SCL, pTmpAlarmTone != null, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_set_str(tmpAlarmHandle, _calendar_alarm.tone, pTmpAlarmTone.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); } else { @@ -1300,19 +1282,21 @@ _CalEventImpl::SetReminder(const Reminder* pReminder) errorCode = calendar_record_create(_calendar_alarm._uri, &tmpAlarmHandle); SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); - errorCode = calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit); - errorCode = calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, pReminder->GetTimeOffset()); + calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit); + calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, pReminder->GetTimeOffset()); errorCode = calendar_record_set_str(tmpAlarmHandle, _calendar_alarm.tone, pTmpAlarmTone.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_add_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); } } else { if (reminderCount > 0) { - errorCode = calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, 0, &tmpAlarmHandle); - errorCode = calendar_record_remove_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle); + calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, 0, &tmpAlarmHandle); + calendar_record_remove_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle); } } @@ -1341,14 +1325,14 @@ _CalEventImpl::SetRecurrence(const Recurrence* pRecurrence) std::unique_ptr pExDates(_StringConverter::CopyToCharArrayN(ConvertRecurrenceToRRuleExDateString(*pRecurrence, IsAllDayEvent()))); errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.exdate, pExDates.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); __pRecurrence.reset(new (std::nothrow) Recurrence(*pRecurrence)); SysTryReturnResult(NID_SCL, __pRecurrence != null, E_OUT_OF_MEMORY, "Memory allocation failed."); } else { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.freq, CALENDAR_RECURRENCE_NONE); + calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.freq, CALENDAR_RECURRENCE_NONE); __pRecurrence.reset(null); } @@ -1392,16 +1376,18 @@ _CalEventImpl::AddReminder(const Reminder& reminder) break; } - errorCode = calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit); - errorCode = calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, reminder.GetTimeOffset()); + calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit); + calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, reminder.GetTimeOffset()); errorCode = calendar_record_set_str(tmpAlarmHandle, _calendar_alarm.tone, pTmpAlarmTone.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); if (convertedTimeUnit == CALENDAR_ALARM_TIME_UNIT_SPECIFIC) { - errorCode = calendar_record_set_lli(tmpAlarmHandle, _calendar_alarm.time, _CalendarbookUtil::ConvertDateTimeToEpochTime(reminder.GetAbsoluteTime())); + calendar_record_set_lli(tmpAlarmHandle, _calendar_alarm.time, _CalendarbookUtil::ConvertDateTimeToEpochTime(reminder.GetAbsoluteTime())); } errorCode = calendar_record_add_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); __reminderList.RemoveAll(true); __reminderListUpdated = false; @@ -1418,7 +1404,7 @@ _CalEventImpl::RemoveReminderAt(int index) errorCode = calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, index, &tmpAlarmHandle); SysTryReturnResult(NID_SCL, tmpAlarmHandle != null, E_OUT_OF_RANGE, "The index is out of range. index = %d", index); - errorCode = calendar_record_remove_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle); + calendar_record_remove_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle); __reminderList.RemoveAll(true); __reminderListUpdated = false; @@ -1476,14 +1462,14 @@ _CalEventImpl::ConvertRecurrenceToEventHandle(const Recurrence& recurrence, cale { if (*recurrence.GetUntil() == DateTime::GetMaxValue()) { - errorCode = calendar_record_set_int(eventHandle, _calendar_event.range_type, CALENDAR_RANGE_NONE); + calendar_record_set_int(eventHandle, _calendar_event.range_type, CALENDAR_RANGE_NONE); } else { calendar_time_s startCalendarTime; calendar_time_s untilCalendarTime; - errorCode = calendar_record_get_caltime(eventHandle, _calendar_event.start_time, &startCalendarTime); + calendar_record_get_caltime(eventHandle, _calendar_event.start_time, &startCalendarTime); if (startCalendarTime.type == CALENDAR_TIME_LOCALTIME) { untilCalendarTime.type = CALENDAR_TIME_LOCALTIME; @@ -1497,25 +1483,25 @@ _CalEventImpl::ConvertRecurrenceToEventHandle(const Recurrence& recurrence, cale untilCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(*recurrence.GetUntil()); } - errorCode = calendar_record_set_int(eventHandle, _calendar_event.range_type, CALENDAR_RANGE_UNTIL); - errorCode = calendar_record_set_caltime(eventHandle, _calendar_event.until_time, untilCalendarTime); + calendar_record_set_int(eventHandle, _calendar_event.range_type, CALENDAR_RANGE_UNTIL); + calendar_record_set_caltime(eventHandle, _calendar_event.until_time, untilCalendarTime); } } else { - errorCode = calendar_record_set_int(eventHandle, _calendar_event.range_type, CALENDAR_RANGE_COUNT); - errorCode = calendar_record_set_int(eventHandle, _calendar_event.count, recurrence.GetCounts()); + calendar_record_set_int(eventHandle, _calendar_event.range_type, CALENDAR_RANGE_COUNT); + calendar_record_set_int(eventHandle, _calendar_event.count, recurrence.GetCounts()); } - errorCode = calendar_record_set_int(eventHandle, _calendar_event.interval, recurrence.GetInterval()); + calendar_record_set_int(eventHandle, _calendar_event.interval, recurrence.GetInterval()); switch (recurrence.GetFrequency()) { case FREQ_DAILY: - errorCode = calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_DAILY); + calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_DAILY); break; case FREQ_WEEKLY: - errorCode = calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_WEEKLY); + calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_WEEKLY); dayOfWeek = recurrence.GetDayOfWeek(); r = ConvertDayOfWeekToRRuleByDayString(dayOfWeek, 0, dayOfWeekString); @@ -1525,7 +1511,7 @@ _CalEventImpl::ConvertRecurrenceToEventHandle(const Recurrence& recurrence, cale break; case FREQ_MONTHLY: - errorCode = calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_MONTHLY); + calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_MONTHLY); if (recurrence.GetDayOfMonth() != 0) { @@ -1542,7 +1528,7 @@ _CalEventImpl::ConvertRecurrenceToEventHandle(const Recurrence& recurrence, cale break; case FREQ_YEARLY: - errorCode = calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_YEARLY); + calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_YEARLY); pByMonth.reset(_StringConverter::CopyToCharArrayN(Integer::ToString(recurrence.GetMonthOfYear()))); @@ -1566,8 +1552,11 @@ _CalEventImpl::ConvertRecurrenceToEventHandle(const Recurrence& recurrence, cale } errorCode = calendar_record_set_str(eventHandle, _calendar_event.byday, pByDay.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_set_str(eventHandle, _calendar_event.bymonth, pByMonth.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_set_str(eventHandle, _calendar_event.bymonthday, pByMonthDay.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); return E_SUCCESS; } @@ -1625,10 +1614,9 @@ _CalEventImpl::ConvertDayOfWeekToRRuleByDayString(int dayOfWeek, int weekOfMonth RecordId _CalEventImpl::GetCalendarId(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcCalendarbookId = 0; - errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.calendar_book_id, &srcCalendarbookId); + calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.calendar_book_id, &srcCalendarbookId); return srcCalendarbookId; } @@ -1636,10 +1624,9 @@ _CalEventImpl::GetCalendarId(void) const RecordId _CalEventImpl::GetBaseEventId(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcBaseEventId = INVALID_RECORD_ID; - errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.original_event_id, &srcBaseEventId); + calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.original_event_id, &srcBaseEventId); return srcBaseEventId; } @@ -1657,15 +1644,14 @@ _CalEventImpl::GetAttendeeIndex(const char* pAttendeeEmail) int index = _INVALID_ATTENDEE_INDEX; unsigned int attendeeCount = 0; - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_get_child_record_count(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, &attendeeCount); + calendar_record_get_child_record_count(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, &attendeeCount); calendar_record_h tmpAttendeeHandle = null; char* pTmpAttendeeEmail = null; for (int i = 0; i < attendeeCount; i++) { - errorCode = calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, i, &tmpAttendeeHandle); - errorCode = calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.email, &pTmpAttendeeEmail); + calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, i, &tmpAttendeeHandle); + calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.email, &pTmpAttendeeEmail); if (strcmp(pAttendeeEmail, pTmpAttendeeEmail) == 0) { @@ -2153,8 +2139,6 @@ _CalEventImpl::ConvertRRuleExDateStringToRecurrence(const String& exdate, Recurr String _CalEventImpl::ConvertRecurrenceToRRuleExDateString(const Recurrence& recurrence, bool isDate) const { - result r = E_SUCCESS; - bool isNotFirst = false; String exdateString; @@ -2167,10 +2151,10 @@ _CalEventImpl::ConvertRecurrenceToRRuleExDateString(const Recurrence& recurrence if (isNotFirst) { - r = exdateString.Append(_RECURRENCE_DELIMITER); + exdateString.Append(_RECURRENCE_DELIMITER); } - r = exdateString.Append(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(*pDateTime, isDate)); + exdateString.Append(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(*pDateTime, isDate)); isNotFirst = true; } diff --git a/src/FScl_CalTodoImpl.cpp b/src/FScl_CalTodoImpl.cpp index 10cc31d..490257f 100644 --- a/src/FScl_CalTodoImpl.cpp +++ b/src/FScl_CalTodoImpl.cpp @@ -73,15 +73,15 @@ _CalTodoImpl::_CalTodoImpl(void) tmpDateTime = _CalendarbookImpl::GetMinDateTime(); ClearLastResult(); } - r = tmpDateTime.SetValue(tmpDateTime.GetYear(), tmpDateTime.GetMonth(), tmpDateTime.GetDay(), 0, 0, 0); + tmpDateTime.SetValue(tmpDateTime.GetYear(), tmpDateTime.GetMonth(), tmpDateTime.GetDay(), 0, 0, 0); calendar_time_s convertedCalendarTime; convertedCalendarTime.type = CALENDAR_TIME_UTIME; convertedCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(tmpDateTime); - errorCode = calendar_record_set_caltime(todoHandle, _calendar_todo.start_time, convertedCalendarTime); - errorCode = calendar_record_set_caltime(todoHandle, _calendar_todo.due_time, convertedCalendarTime); + calendar_record_set_caltime(todoHandle, _calendar_todo.start_time, convertedCalendarTime); + calendar_record_set_caltime(todoHandle, _calendar_todo.due_time, convertedCalendarTime); } else { @@ -93,14 +93,14 @@ _CalTodoImpl::_CalTodoImpl(void) convertedDueTime.type = CALENDAR_TIME_UTIME; convertedDueTime.time.utime = _CALENDAR_TODO_NO_DUE_DATE; - errorCode = calendar_record_set_caltime(todoHandle, _calendar_todo.start_time, convertedStartTime); - errorCode = calendar_record_set_caltime(todoHandle, _calendar_todo.due_time, convertedDueTime); + calendar_record_set_caltime(todoHandle, _calendar_todo.start_time, convertedStartTime); + calendar_record_set_caltime(todoHandle, _calendar_todo.due_time, convertedDueTime); } // default value - errorCode = calendar_record_set_int(todoHandle, _calendar_todo.todo_status, CALENDAR_TODO_STATUS_NONE); - errorCode = calendar_record_set_int(todoHandle, _calendar_todo.priority, CALENDAR_TODO_PRIORITY_NORMAL); - errorCode = calendar_record_set_int(todoHandle, _calendar_todo.sensitivity, CALENDAR_SENSITIVITY_PUBLIC); + calendar_record_set_int(todoHandle, _calendar_todo.todo_status, CALENDAR_TODO_STATUS_NONE); + calendar_record_set_int(todoHandle, _calendar_todo.priority, CALENDAR_TODO_PRIORITY_NORMAL); + calendar_record_set_int(todoHandle, _calendar_todo.sensitivity, CALENDAR_SENSITIVITY_PUBLIC); __todoRecord.ResetHandle(todoHandle); @@ -159,10 +159,9 @@ _CalTodoImpl::operator =(const _CalTodoImpl& rhs) String _CalTodoImpl::GetSubject(void) const { - int errorCode = CALENDAR_ERROR_NONE; char* pSubject = null; - errorCode = calendar_record_get_str_p(__todoRecord.GetHandle(), _calendar_todo.summary, &pSubject); + calendar_record_get_str_p(__todoRecord.GetHandle(), _calendar_todo.summary, &pSubject); return String(pSubject); } @@ -170,10 +169,9 @@ _CalTodoImpl::GetSubject(void) const String _CalTodoImpl::GetDescription(void) const { - int errorCode = CALENDAR_ERROR_NONE; char* pDescription = null; - errorCode = calendar_record_get_str_p(__todoRecord.GetHandle(), _calendar_todo.description, &pDescription); + calendar_record_get_str_p(__todoRecord.GetHandle(), _calendar_todo.description, &pDescription); return String(pDescription); } @@ -183,10 +181,9 @@ _CalTodoImpl::GetStartDate(void) const { ClearLastResult(); - int errorCode = CALENDAR_ERROR_NONE; calendar_time_s tmpCalendarTime; - errorCode = calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, &tmpCalendarTime); + calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, &tmpCalendarTime); if (tmpCalendarTime.time.utime == _CALENDAR_TODO_NO_START_DATE) { @@ -204,10 +201,9 @@ _CalTodoImpl::GetDueDate(void) const { ClearLastResult(); - int errorCode = CALENDAR_ERROR_NONE; calendar_time_s tmpCalendarTime; - errorCode = calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, &tmpCalendarTime); + calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, &tmpCalendarTime); if (tmpCalendarTime.time.utime == _CALENDAR_TODO_NO_DUE_DATE) { @@ -223,12 +219,11 @@ _CalTodoImpl::GetDueDate(void) const TodoPriority _CalTodoImpl::GetPriority(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcPriority = CALENDAR_EVENT_PRIORITY_LOW; TodoPriority priority = TODO_PRIORITY_NORMAL; - errorCode = calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.priority, &srcPriority); + calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.priority, &srcPriority); switch (srcPriority) { @@ -255,12 +250,11 @@ _CalTodoImpl::GetPriority(void) const TodoStatus _CalTodoImpl::GetStatus(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcStatus = CALENDAR_EVENT_STATUS_NONE; TodoStatus status = TODO_STATUS_NONE; - errorCode = calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.todo_status, &srcStatus); + calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.todo_status, &srcStatus); switch (srcStatus) { @@ -291,11 +285,10 @@ _CalTodoImpl::GetStatus(void) const RecordSensitivity _CalTodoImpl::GetSensitivity(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcSensitivity = CALENDAR_SENSITIVITY_PUBLIC; RecordSensitivity sensitivity = SENSITIVITY_PUBLIC; - errorCode = calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.sensitivity, &srcSensitivity); + calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.sensitivity, &srcSensitivity); switch (srcSensitivity) { @@ -320,11 +313,10 @@ _CalTodoImpl::GetSensitivity(void) const DateTime _CalTodoImpl::GetLastRevisedTime(void) const { - int errorCode = CALENDAR_ERROR_NONE; long long lastModifiedTime = 0; DateTime tmpLastRevisedTime; - errorCode = calendar_record_get_lli(__todoRecord.GetHandle(), _calendar_todo.last_modified_time, &lastModifiedTime); + calendar_record_get_lli(__todoRecord.GetHandle(), _calendar_todo.last_modified_time, &lastModifiedTime); tmpLastRevisedTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(lastModifiedTime); @@ -345,6 +337,7 @@ _CalTodoImpl::SetSubject(const String& subject) int errorCode = CALENDAR_ERROR_NONE; errorCode = calendar_record_set_str(__todoRecord.GetHandle(), _calendar_todo.summary, pConvertedSubject.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); return E_SUCCESS; } @@ -363,6 +356,7 @@ _CalTodoImpl::SetDescription(const String& description) int errorCode = CALENDAR_ERROR_NONE; errorCode = calendar_record_set_str(__todoRecord.GetHandle(), _calendar_todo.description, pConvertedDescription.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); return E_SUCCESS; } @@ -374,7 +368,6 @@ _CalTodoImpl::SetStartAndDueDate(const DateTime& startDate, const DateTime& dueD SysTryReturnResult(NID_SCL, _CalendarbookUtil::CheckValidDateTime(dueDate), E_INVALID_ARG, "Invalid argument is used. The end date is invalid."); SysTryReturnResult(NID_SCL, startDate <= dueDate, E_INVALID_ARG, "Invalid argument is used. The end date is earlier than the start date."); - int errorCode = CALENDAR_ERROR_NONE; calendar_time_s convertedStartTime; calendar_time_s convertedDueTime; @@ -383,8 +376,8 @@ _CalTodoImpl::SetStartAndDueDate(const DateTime& startDate, const DateTime& dueD convertedDueTime.type = CALENDAR_TIME_UTIME; convertedDueTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(dueDate); - errorCode = calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, convertedStartTime); - errorCode = calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, convertedDueTime); + calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, convertedStartTime); + calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, convertedDueTime); return E_SUCCESS; } @@ -392,7 +385,6 @@ _CalTodoImpl::SetStartAndDueDate(const DateTime& startDate, const DateTime& dueD result _CalTodoImpl::SetStartDate(const DateTime& startDate) { - int errorCode = CALENDAR_ERROR_NONE; calendar_time_s convertedStartTime; convertedStartTime.type = CALENDAR_TIME_UTIME; @@ -408,19 +400,18 @@ _CalTodoImpl::SetStartDate(const DateTime& startDate) else { calendar_time_s convertedDueTime; - errorCode = calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, &convertedDueTime); + calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, &convertedDueTime); convertedStartTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(startDate); if (convertedStartTime.time.utime > convertedDueTime.time.utime) { convertedDueTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(DateTime::GetMinValue()); - errorCode = calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, convertedDueTime); + calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, convertedDueTime); } } - errorCode = calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, convertedStartTime); - + calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, convertedStartTime); return E_SUCCESS; } @@ -428,7 +419,6 @@ _CalTodoImpl::SetStartDate(const DateTime& startDate) result _CalTodoImpl::SetDueDate(const DateTime& dueDate) { - int errorCode = CALENDAR_ERROR_NONE; calendar_time_s convertedDueTime; convertedDueTime.type = CALENDAR_TIME_UTIME; @@ -444,18 +434,18 @@ _CalTodoImpl::SetDueDate(const DateTime& dueDate) else { calendar_time_s convertedStartTime; - errorCode = calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, &convertedStartTime); + calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, &convertedStartTime); convertedDueTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(dueDate); if (convertedStartTime.time.utime > convertedDueTime.time.utime) { convertedStartTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(DateTime::GetMinValue()); - errorCode = calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, convertedStartTime); + calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, convertedStartTime); } } - errorCode = calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, convertedDueTime); + calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, convertedDueTime); return E_SUCCESS; } @@ -463,22 +453,19 @@ _CalTodoImpl::SetDueDate(const DateTime& dueDate) void _CalTodoImpl::SetPriority(TodoPriority priority) { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_set_int(__todoRecord.GetHandle(), _calendar_todo.priority, _CalendarbookUtil::ConvertTodoPriorityToCSTodoPriority(priority)); + calendar_record_set_int(__todoRecord.GetHandle(), _calendar_todo.priority, _CalendarbookUtil::ConvertTodoPriorityToCSTodoPriority(priority)); } void _CalTodoImpl::SetStatus(TodoStatus status) { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_set_int(__todoRecord.GetHandle(), _calendar_todo.todo_status, _CalendarbookUtil::ConvertTodoStatusToCSTodoStatus(status)); + calendar_record_set_int(__todoRecord.GetHandle(), _calendar_todo.todo_status, _CalendarbookUtil::ConvertTodoStatusToCSTodoStatus(status)); } void _CalTodoImpl::SetSensitivity(RecordSensitivity sensitivity) { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_set_int(__todoRecord.GetHandle(), _calendar_todo.sensitivity, _CalendarbookUtil::ConvertSensitivityToCSSensitivity(sensitivity)); + calendar_record_set_int(__todoRecord.GetHandle(), _calendar_todo.sensitivity, _CalendarbookUtil::ConvertSensitivityToCSSensitivity(sensitivity)); } void @@ -489,15 +476,15 @@ _CalTodoImpl::SetLocation(const String& location) int errorCode = CALENDAR_ERROR_NONE; errorCode = calendar_record_set_str(__todoRecord.GetHandle(), _calendar_todo.location, pConvertedLocation.get()); + SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } String _CalTodoImpl::GetLocation(void) const { - int errorCode = CALENDAR_ERROR_NONE; char* pLocation = null; - errorCode = calendar_record_get_str_p(__todoRecord.GetHandle(), _calendar_todo.location, &pLocation); + calendar_record_get_str_p(__todoRecord.GetHandle(), _calendar_todo.location, &pLocation); return String(pLocation); } @@ -508,10 +495,8 @@ _CalTodoImpl::SetCoordinates(double latitude, double longitude) SysTryReturnResult(NID_SCL, latitude >= _MIN_LATITUDE && latitude <= _MAX_LATITUDE, E_INVALID_ARG, "Invalid argument is used. The latitude is out of range."); SysTryReturnResult(NID_SCL, longitude >= _MIN_LONGITUDE && longitude <= _MAX_LONGITUDE, E_INVALID_ARG, "Invalid argument is used. The longitude is out of range."); - int errorCode = CALENDAR_ERROR_NONE; - - errorCode = calendar_record_set_double(__todoRecord.GetHandle(), _calendar_todo.latitude, latitude); - errorCode = calendar_record_set_double(__todoRecord.GetHandle(), _calendar_todo.longitude, longitude); + calendar_record_set_double(__todoRecord.GetHandle(), _calendar_todo.latitude, latitude); + calendar_record_set_double(__todoRecord.GetHandle(), _calendar_todo.longitude, longitude); return E_SUCCESS; } @@ -519,10 +504,8 @@ _CalTodoImpl::SetCoordinates(double latitude, double longitude) void _CalTodoImpl::GetCoordinates(double& latitude, double& longitude) const { - int errorCode = CALENDAR_ERROR_NONE; - - errorCode = calendar_record_get_double(__todoRecord.GetHandle(), _calendar_todo.latitude, &latitude); - errorCode = calendar_record_get_double(__todoRecord.GetHandle(), _calendar_todo.longitude, &longitude); + calendar_record_get_double(__todoRecord.GetHandle(), _calendar_todo.latitude, &latitude); + calendar_record_get_double(__todoRecord.GetHandle(), _calendar_todo.longitude, &longitude); } result @@ -561,16 +544,18 @@ _CalTodoImpl::AddReminder(const Reminder& reminder) break; } - errorCode = calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit); - errorCode = calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, reminder.GetTimeOffset()); + calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit); + calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, reminder.GetTimeOffset()); errorCode = calendar_record_set_str(tmpAlarmHandle, _calendar_alarm.tone, pTmpAlarmTone.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); if (convertedTimeUnit == CALENDAR_ALARM_TIME_UNIT_SPECIFIC) { - errorCode = calendar_record_set_lli(tmpAlarmHandle, _calendar_alarm.time, _CalendarbookUtil::ConvertDateTimeToEpochTime(reminder.GetAbsoluteTime())); + calendar_record_set_lli(tmpAlarmHandle, _calendar_alarm.time, _CalendarbookUtil::ConvertDateTimeToEpochTime(reminder.GetAbsoluteTime())); } errorCode = calendar_record_add_child_record(__todoRecord.GetHandle(), _calendar_todo.calendar_alarm, tmpAlarmHandle); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); __reminderList.RemoveAll(true); __reminderListUpdated = false; @@ -587,7 +572,7 @@ _CalTodoImpl::RemoveReminderAt(int index) errorCode = calendar_record_get_child_record_at_p(__todoRecord.GetHandle(), _calendar_todo.calendar_alarm, index, &tmpAlarmHandle); SysTryReturnResult(NID_SCL, tmpAlarmHandle != null, E_OUT_OF_RANGE, "The index is either equal to or greater than the number of reminders or less than 0."); - errorCode = calendar_record_remove_child_record(__todoRecord.GetHandle(), _calendar_todo.calendar_alarm, tmpAlarmHandle); + calendar_record_remove_child_record(__todoRecord.GetHandle(), _calendar_todo.calendar_alarm, tmpAlarmHandle); __reminderList.RemoveAll(true); __reminderListUpdated = false; @@ -614,10 +599,9 @@ _CalTodoImpl::GetAllReminders(void) const RecordId _CalTodoImpl::GetCalendarId(void) const { - int errorCode = CALENDAR_ERROR_NONE; int srcCalendarbookId = 0; - errorCode = calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.calendar_book_id, &srcCalendarbookId); + calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.calendar_book_id, &srcCalendarbookId); return srcCalendarbookId; } diff --git a/src/FScl_CalendarImpl.cpp b/src/FScl_CalendarImpl.cpp index ff4863e..8dcd8c7 100644 --- a/src/FScl_CalendarImpl.cpp +++ b/src/FScl_CalendarImpl.cpp @@ -51,7 +51,7 @@ _CalendarImpl::_CalendarImpl(CalendarItemType itemType) errorCode = calendar_record_create(_calendar_book._uri, &calendarHandle); SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - errorCode = calendar_record_set_int(calendarHandle, _calendar_book.store_type, _CalendarbookUtil::ConvertCalendarItemTypeToCSCalendarbookType(itemType)); + calendar_record_set_int(calendarHandle, _calendar_book.store_type, _CalendarbookUtil::ConvertCalendarItemTypeToCSCalendarbookType(itemType)); __calendarRecord.ResetHandle(calendarHandle); @@ -73,9 +73,7 @@ _CalendarImpl::_CalendarImpl(const _CalendarImpl& rhs) _CalendarImpl::~_CalendarImpl(void) { - int errorCode = CALENDAR_ERROR_NONE; - - errorCode = calendar_record_destroy(__calendarRecord.ReleaseHandle(), true); + calendar_record_destroy(__calendarRecord.ReleaseHandle(), true); result r = _CalendarbookDbConnector::Disconnect(); SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); @@ -103,10 +101,9 @@ _CalendarImpl::operator =(const _CalendarImpl& rhs) String _CalendarImpl::GetName(void) const { - int errorCode = CALENDAR_ERROR_NONE; char* pName = null; - errorCode = calendar_record_get_str_p(__calendarRecord.GetHandle(), _calendar_book.name, &pName); + calendar_record_get_str_p(__calendarRecord.GetHandle(), _calendar_book.name, &pName); return String(pName); } @@ -114,11 +111,10 @@ _CalendarImpl::GetName(void) const CalendarItemType _CalendarImpl::GetItemType(void) const { - int errorCode = CALENDAR_ERROR_NONE; int storeType = 0; CalendarItemType calendarItemType = CALENDAR_ITEM_TYPE_EVENT_AND_TODO; - errorCode = calendar_record_get_int(__calendarRecord.GetHandle(), _calendar_book.store_type, &storeType); + calendar_record_get_int(__calendarRecord.GetHandle(), _calendar_book.store_type, &storeType); switch (storeType) { @@ -142,9 +138,8 @@ _CalendarImpl::GetItemType(void) const AccountId _CalendarImpl::GetAccountId(void) const { - int errorCode = CALENDAR_ERROR_NONE; int accountId = 0; - errorCode = calendar_record_get_int(__calendarRecord.GetHandle(), _calendar_book.account_id, &accountId); + calendar_record_get_int(__calendarRecord.GetHandle(), _calendar_book.account_id, &accountId); return accountId; } @@ -152,9 +147,8 @@ _CalendarImpl::GetAccountId(void) const result _CalendarImpl::GetColor(byte& red, byte& green, byte& blue) const { - int errorCode = CALENDAR_ERROR_NONE; char* pColor = null; - errorCode = calendar_record_get_str_p(__calendarRecord.GetHandle(), _calendar_book.color, &pColor); + calendar_record_get_str_p(__calendarRecord.GetHandle(), _calendar_book.color, &pColor); if (pColor == null || strlen(pColor) == 0) { @@ -165,8 +159,6 @@ _CalendarImpl::GetColor(byte& red, byte& green, byte& blue) const return E_DATA_NOT_FOUND; } - result r = E_SUCCESS; - int tmpRed = 0; int tmpGreen = 0; int tmpBlue = 0; @@ -177,12 +169,12 @@ _CalendarImpl::GetColor(byte& red, byte& green, byte& blue) const StringTokenizer strTok(tmpString, delim); - r = strTok.GetNextToken(token); - r = Integer::Parse(token, tmpRed); - r = strTok.GetNextToken(token); - r = Integer::Parse(token, tmpGreen); - r = strTok.GetNextToken(token); - r = Integer::Parse(token, tmpBlue); + strTok.GetNextToken(token); + Integer::Parse(token, tmpRed); + strTok.GetNextToken(token); + Integer::Parse(token, tmpGreen); + strTok.GetNextToken(token); + Integer::Parse(token, tmpBlue); red = tmpRed; green = tmpGreen; @@ -199,6 +191,7 @@ _CalendarImpl::SetName(const String& name) int errorCode = CALENDAR_ERROR_NONE; errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.name, pConvertedName.get()); + SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } void @@ -218,6 +211,7 @@ _CalendarImpl::SetColor(byte red, byte green, byte blue) int errorCode = CALENDAR_ERROR_NONE; errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.color, pConvertedColor.get()); + SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } void @@ -230,13 +224,13 @@ _CalendarImpl::ClearColor(void) int errorCode = CALENDAR_ERROR_NONE; errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.color, pConvertedColor.get()); + SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } void _CalendarImpl::SetAccountId(AccountId accountId) { - int errorCode = CALENDAR_ERROR_NONE; - errorCode = calendar_record_set_int(__calendarRecord.GetHandle(), _calendar_book.account_id, accountId); + calendar_record_set_int(__calendarRecord.GetHandle(), _calendar_book.account_id, accountId); } void diff --git a/src/FScl_CalendarbookImpl.cpp b/src/FScl_CalendarbookImpl.cpp index 745ee5f..56f0a3d 100644 --- a/src/FScl_CalendarbookImpl.cpp +++ b/src/FScl_CalendarbookImpl.cpp @@ -333,7 +333,7 @@ _CalendarbookImpl::AddEvent(CalEvent& event) calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle(); - errorCode = calendar_record_set_int(eventHandle, _calendar_event.calendar_book_id, _DEFAULT_EVENT_CALENDAR_DB_ID); + calendar_record_set_int(eventHandle, _calendar_event.calendar_book_id, _DEFAULT_EVENT_CALENDAR_DB_ID); errorCode = calendar_db_insert_record(eventHandle, &dbIndex); SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient."); SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred."); @@ -366,7 +366,7 @@ _CalendarbookImpl::AddEvent(CalEvent& event, RecordId calendarId) calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle(); - errorCode = calendar_record_set_int(eventHandle, _calendar_event.calendar_book_id, calendarId); + calendar_record_set_int(eventHandle, _calendar_event.calendar_book_id, calendarId); errorCode = calendar_db_insert_record(eventHandle, &dbIndex); SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient."); SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred."); @@ -391,7 +391,7 @@ _CalendarbookImpl::AddTodo(CalTodo& todo) calendar_record_h todoHandle = _CalTodoImpl::GetInstance(todo)->GetRecordHandle(); - errorCode = calendar_record_set_int(todoHandle, _calendar_todo.calendar_book_id, _DEFAULT_TODO_CALENDAR_DB_ID); + calendar_record_set_int(todoHandle, _calendar_todo.calendar_book_id, _DEFAULT_TODO_CALENDAR_DB_ID); errorCode = calendar_db_insert_record(todoHandle, &dbIndex); SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient."); SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred."); @@ -422,7 +422,7 @@ _CalendarbookImpl::AddTodo(CalTodo& todo, RecordId calendarId) calendar_record_h todoHandle = _CalTodoImpl::GetInstance(todo)->GetRecordHandle(); - errorCode = calendar_record_set_int(todoHandle, _calendar_todo.calendar_book_id, calendarId); + calendar_record_set_int(todoHandle, _calendar_todo.calendar_book_id, calendarId); errorCode = calendar_db_insert_record(todoHandle, &dbIndex); SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient."); SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred."); @@ -472,7 +472,7 @@ _CalendarbookImpl::AddCalendar(Calendar& calendar, AccountId accountId) calendar_record_h calendarHandle = _CalendarImpl::GetInstance(calendar)->GetRecordHandle(); - errorCode = calendar_record_set_int(calendarHandle, _calendar_book.account_id, accountId); + calendar_record_set_int(calendarHandle, _calendar_book.account_id, accountId); errorCode = calendar_db_insert_record(calendarHandle, &dbIndex); SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient."); @@ -526,7 +526,7 @@ _CalendarbookImpl::RemoveEvent(RecordId eventId) SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The specified record is not found."); int baseEventId = _INVALID_EVENT_DB_ID; - errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); + calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); calendar_record_destroy(eventHandle, true); @@ -681,7 +681,6 @@ _CalendarbookImpl::GetTodoN(RecordId todoId) const SysTryReturn(NID_SCL, pTodo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_db_get_record(_calendar_todo._uri, todoId, &todoHandle); - 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 specified record is not found."); @@ -746,10 +745,13 @@ _CalendarbookImpl::GetTodosN(const DateTime& start, const DateTime& end, int pag // Condition : Due time of the item >= start time of filter errorCode = calendar_filter_add_caltime(mainFilterHandle, _calendar_todo.due_time, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, convertedStartTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : Due time of the item <= end time of filter errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_caltime(mainFilterHandle, _calendar_todo.due_time, CALENDAR_MATCH_LESS_THAN_OR_EQUAL, convertedEndTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : status calendar_filter_h subFilterHandle = null; @@ -767,9 +769,11 @@ _CalendarbookImpl::GetTodosN(const DateTime& start, const DateTime& end, int pag if (alreadyAdded) { errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_OR); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } errorCode = calendar_filter_add_int(subFilter.GetHandle(), _calendar_todo.todo_status, CALENDAR_MATCH_EQUAL, ConvertTodoStatusToCalendarTodoStatus(tmpStatus)); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); alreadyAdded = true; } @@ -778,7 +782,9 @@ _CalendarbookImpl::GetTodosN(const DateTime& start, const DateTime& end, int pag } errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_filter(mainFilterHandle, subFilter.GetHandle()); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : priority errorCode = calendar_filter_create(_calendar_todo._uri, &subFilterHandle); @@ -795,9 +801,11 @@ _CalendarbookImpl::GetTodosN(const DateTime& start, const DateTime& end, int pag if (alreadyAdded) { errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_OR); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } errorCode = calendar_filter_add_int(subFilter.GetHandle(), _calendar_todo.priority, CALENDAR_MATCH_EQUAL, ConvertTodoPriorityToCalendarTodoPriority(tmpPriority)); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); alreadyAdded = true; } @@ -805,7 +813,9 @@ _CalendarbookImpl::GetTodosN(const DateTime& start, const DateTime& end, int pag } errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_filter(mainFilterHandle, subFilter.GetHandle()); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Create query calendar_query_h queryHandle = null; @@ -813,8 +823,8 @@ _CalendarbookImpl::GetTodosN(const DateTime& start, const DateTime& end, int pag SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); _CalendarQuery query(queryHandle); - errorCode = calendar_query_set_sort(queryHandle, _calendar_todo.due_time, true); - errorCode = calendar_query_set_filter(queryHandle, mainFilterHandle); + calendar_query_set_sort(queryHandle, _calendar_todo.due_time, true); + calendar_query_set_filter(queryHandle, mainFilterHandle); calendar_list_h calendarListHandle = null; errorCode = calendar_db_get_records_with_query(queryHandle, (pageNo - 1) * countPerPage, countPerPage, &calendarListHandle); @@ -828,7 +838,7 @@ _CalendarbookImpl::GetTodosN(const DateTime& start, const DateTime& end, int pag SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(calendarListHandle, &count); + calendar_list_get_count(calendarListHandle, &count); for (int i = 0; i < count; i++) { @@ -839,25 +849,25 @@ _CalendarbookImpl::GetTodosN(const DateTime& start, const DateTime& end, int pag SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); std::unique_ptr pEnum(pList->GetEnumeratorN()); while (pEnum->MoveNext() == E_SUCCESS) { CalTodo* pTmpTodo = static_cast(pEnum->GetCurrent()); calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); _CalTodoImpl::GetInstance(*pTmpTodo)->SetRecordHandle(tmpRecordHandle); int dbIndex = -1; - errorCode = calendar_record_get_int(tmpRecordHandle, _calendar_todo.id, &dbIndex); + calendar_record_get_int(tmpRecordHandle, _calendar_todo.id, &dbIndex); _RecordImpl::GetInstance(*pTmpTodo)->SetRecordId(dbIndex); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_next(calendarListHandle); } - errorCode = calendar_list_destroy(calendarList.ReleaseHandle(), false); + calendar_list_destroy(calendarList.ReleaseHandle(), false); return pList.release(); } @@ -896,10 +906,13 @@ _CalendarbookImpl::GetTodoCount(const DateTime& start, const DateTime& end, unsi // Condition : Due time of the item => start time of filter errorCode = calendar_filter_add_caltime(mainFilterHandle, _calendar_todo.due_time, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, convertedStartTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : Due time of the item <= end time of filter errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_caltime(mainFilterHandle, _calendar_todo.due_time, CALENDAR_MATCH_LESS_THAN_OR_EQUAL, convertedEndTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : status calendar_filter_h subFilterHandle = null; @@ -917,9 +930,11 @@ _CalendarbookImpl::GetTodoCount(const DateTime& start, const DateTime& end, unsi if (alreadyAdded) { errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_OR); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } errorCode = calendar_filter_add_int(subFilter.GetHandle(), _calendar_todo.todo_status, CALENDAR_MATCH_EQUAL, ConvertTodoStatusToCalendarTodoStatus(tmpStatus)); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); alreadyAdded = true; } @@ -927,7 +942,9 @@ _CalendarbookImpl::GetTodoCount(const DateTime& start, const DateTime& end, unsi tmpStatus <<= 1; } errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_filter(mainFilterHandle, subFilter.GetHandle()); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : priority errorCode = calendar_filter_create(_calendar_todo._uri, &subFilterHandle); @@ -944,9 +961,11 @@ _CalendarbookImpl::GetTodoCount(const DateTime& start, const DateTime& end, unsi if (alreadyAdded) { errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_OR); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } errorCode = calendar_filter_add_int(subFilter.GetHandle(), _calendar_todo.priority, CALENDAR_MATCH_EQUAL, ConvertTodoPriorityToCalendarTodoPriority(tmpPriority)); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); alreadyAdded = true; } @@ -954,7 +973,9 @@ _CalendarbookImpl::GetTodoCount(const DateTime& start, const DateTime& end, unsi } errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_filter(mainFilterHandle, subFilter.GetHandle()); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Create query calendar_query_h queryHandle = null; @@ -962,7 +983,7 @@ _CalendarbookImpl::GetTodoCount(const DateTime& start, const DateTime& end, unsi SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, _INVALID_COUNT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); _CalendarQuery query(queryHandle); - errorCode = calendar_query_set_filter(queryHandle, mainFilterHandle); + calendar_query_set_filter(queryHandle, mainFilterHandle); int count = _INVALID_COUNT; @@ -1055,7 +1076,7 @@ _CalendarbookImpl::GetAllEventsN(void) const SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(calendarListHandle, &count); + calendar_list_get_count(calendarListHandle, &count); for (int i = 0; i < count; i++) { @@ -1066,24 +1087,24 @@ _CalendarbookImpl::GetAllEventsN(void) const SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); std::unique_ptr pEnum(pList->GetEnumeratorN()); while (pEnum->MoveNext() == E_SUCCESS) { CalEvent* pTmpEvent = static_cast(pEnum->GetCurrent()); calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); _CalEventImpl::GetInstance(*pTmpEvent)->SetRecordHandle(tmpRecordHandle); int dbIndex = -1; - errorCode = calendar_record_get_int(tmpRecordHandle, _calendar_event.id, &dbIndex); + calendar_record_get_int(tmpRecordHandle, _calendar_event.id, &dbIndex); _RecordImpl::GetInstance(*pTmpEvent)->SetRecordId(dbIndex); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_next(calendarListHandle); } - errorCode = calendar_list_destroy(calendarList.ReleaseHandle(), false); + calendar_list_destroy(calendarList.ReleaseHandle(), false); return pList.release(); } @@ -1106,7 +1127,7 @@ _CalendarbookImpl::GetAllTodosN(void) const SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(calendarListHandle, &count); + calendar_list_get_count(calendarListHandle, &count); for (int i = 0; i < count; i++) { @@ -1117,24 +1138,24 @@ _CalendarbookImpl::GetAllTodosN(void) const SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); std::unique_ptr pEnum(pList->GetEnumeratorN()); while (pEnum->MoveNext() == E_SUCCESS) { CalTodo* pTmpTodo = static_cast(pEnum->GetCurrent()); calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); _CalTodoImpl::GetInstance(*pTmpTodo)->SetRecordHandle(tmpRecordHandle); int dbIndex = -1; - errorCode = calendar_record_get_int(tmpRecordHandle, _calendar_todo.id, &dbIndex); + calendar_record_get_int(tmpRecordHandle, _calendar_todo.id, &dbIndex); _RecordImpl::GetInstance(*pTmpTodo)->SetRecordId(dbIndex); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_next(calendarListHandle); } - errorCode = calendar_list_destroy(calendarList.ReleaseHandle(), false); + calendar_list_destroy(calendarList.ReleaseHandle(), false); return pList.release(); } @@ -1157,7 +1178,7 @@ _CalendarbookImpl::GetAllCalendarsN(void) const SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(calendarListHandle, &count); + calendar_list_get_count(calendarListHandle, &count); for (int i = 0; i < count; i++) { @@ -1168,24 +1189,24 @@ _CalendarbookImpl::GetAllCalendarsN(void) const SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); std::unique_ptr pEnum(pList->GetEnumeratorN()); while (pEnum->MoveNext() == E_SUCCESS) { Calendar* pTmpCalendar = static_cast(pEnum->GetCurrent()); calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); _CalendarImpl::GetInstance(*pTmpCalendar)->SetRecordHandle(tmpRecordHandle); int dbIndex = -1; - errorCode = calendar_record_get_int(tmpRecordHandle, _calendar_book.id, &dbIndex); + calendar_record_get_int(tmpRecordHandle, _calendar_book.id, &dbIndex); _RecordImpl::GetInstance(*pTmpCalendar)->SetRecordId(dbIndex); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_next(calendarListHandle); } - errorCode = calendar_list_destroy(calendarList.ReleaseHandle(), false); + calendar_list_destroy(calendarList.ReleaseHandle(), false); return pList.release(); } @@ -1213,13 +1234,13 @@ _CalendarbookImpl::GetChangedEventsAfterN(int version, int& latestVersion) const SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(calendarListHandle, &count); + calendar_list_get_count(calendarListHandle, &count); - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); for (int i = 0; i < count; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); std::unique_ptr pChangedInfo(_CalendarbookImpl::ConvertModifiedEventToCalEventChangeInfoN(tmpRecordHandle)); SysTryReturn(NID_SCL, pChangedInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); @@ -1227,7 +1248,7 @@ _CalendarbookImpl::GetChangedEventsAfterN(int version, int& latestVersion) const r = pList->Add(*pChangedInfo.release()); SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_next(calendarListHandle); } latestVersion = tmpLatestVersion; @@ -1259,13 +1280,13 @@ _CalendarbookImpl::GetChangedTodosAfterN(int version, int& latestVersion) const SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(calendarListHandle, &count); + calendar_list_get_count(calendarListHandle, &count); - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); for (int i = 0; i < count; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); std::unique_ptr pChangedInfo(_CalendarbookImpl::ConvertModifiedTodoToCalTodoChangeInfoN(tmpRecordHandle)); SysTryReturn(NID_SCL, pChangedInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); @@ -1273,7 +1294,7 @@ _CalendarbookImpl::GetChangedTodosAfterN(int version, int& latestVersion) const r = pList->Add(*pChangedInfo.release()); SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_next(calendarListHandle); } latestVersion = tmpLatestVersion; @@ -1284,7 +1305,6 @@ _CalendarbookImpl::GetChangedTodosAfterN(int version, int& latestVersion) const result _CalendarbookImpl::RemoveEventInstance(const CalEventInstance& eventInstance) { - result r = E_SUCCESS; int errorCode = CALENDAR_ERROR_NONE; calendar_record_h eventHandle = null; @@ -1297,7 +1317,7 @@ _CalendarbookImpl::RemoveEventInstance(const CalEventInstance& eventInstance) _CalendarRecord eventRecord(eventHandle); int baseEventId = _INVALID_EVENT_DB_ID; - errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); + calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); if (baseEventId != _INVALID_EVENT_DB_ID) { @@ -1307,21 +1327,22 @@ _CalendarbookImpl::RemoveEventInstance(const CalEventInstance& eventInstance) else { // Append exdate - errorCode = calendar_record_get_str_p(eventHandle, _calendar_event.exdate, &pExdate); + calendar_record_get_str_p(eventHandle, _calendar_event.exdate, &pExdate); String exdate; if (pExdate != null && strlen(pExdate) > 0) { exdate.Append(pExdate); - r = exdate.Append(_RECURRENCE_DELIMITER); + exdate.Append(_RECURRENCE_DELIMITER); } - r = exdate.Append(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(eventInstance.GetStartTime(), eventInstance.IsAllDayEvent())); + exdate.Append(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(eventInstance.GetStartTime(), eventInstance.IsAllDayEvent())); std::unique_ptr pAppendedExdate(_StringConverter::CopyToCharArrayN(exdate)); SysTryReturnResult(NID_SCL, pAppendedExdate != null, E_OUT_OF_MEMORY, "Memory allocation failed."); errorCode = calendar_record_set_str(eventHandle, _calendar_event.exdate, pAppendedExdate.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); // Update event handle errorCode = calendar_db_update_record(eventHandle); @@ -1334,7 +1355,6 @@ _CalendarbookImpl::RemoveEventInstance(const CalEventInstance& eventInstance) result _CalendarbookImpl::UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event) { - result r = E_SUCCESS; int errorCode = CALENDAR_ERROR_NONE; SysTryReturnResult(NID_SCL, event.GetRecordId() != INVALID_RECORD_ID, E_INVALID_ARG @@ -1349,7 +1369,7 @@ _CalendarbookImpl::UpdateEventInstance(const CalEventInstance& eventInstance, Ca _CalendarRecord eventRecord(eventHandle); int baseEventId = _INVALID_EVENT_DB_ID; - errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); + calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); calendar_record_h baseEventHandle = null; if (baseEventId == _INVALID_EVENT_DB_ID) @@ -1365,23 +1385,24 @@ _CalendarbookImpl::UpdateEventInstance(const CalEventInstance& eventInstance, Ca _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_record_get_int(baseEventHandle, _calendar_event.freq, &tmpIntValue); + calendar_record_set_int(eventHandle, _calendar_event.freq, tmpIntValue); + calendar_record_get_int(baseEventHandle, _calendar_event.range_type, &tmpIntValue); + calendar_record_set_int(eventHandle, _calendar_event.range_type, tmpIntValue); + calendar_record_get_int(baseEventHandle, _calendar_event.count, &tmpIntValue); + calendar_record_set_int(eventHandle, _calendar_event.count, tmpIntValue); + calendar_record_get_int(baseEventHandle, _calendar_event.interval, &tmpIntValue); + calendar_record_set_int(eventHandle, _calendar_event.interval, tmpIntValue); + calendar_record_get_int(baseEventHandle, _calendar_event.wkst, &tmpIntValue); + calendar_record_set_int(eventHandle, _calendar_event.wkst, tmpIntValue); calendar_time_s tmpTimeValue; - errorCode = calendar_record_get_caltime(baseEventHandle, _calendar_event.until_time, &tmpTimeValue); + 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); + calendar_record_get_caltime(eventHandle, _calendar_event.start_time, &tmpStartTimeValue); if (tmpTimeValue.type != tmpStartTimeValue.type) { @@ -1400,24 +1421,32 @@ _CalendarbookImpl::UpdateEventInstance(const CalEventInstance& eventInstance, Ca tmpTimeValue.time.date.mday = convertedTime.GetDay(); } } - errorCode = calendar_record_set_caltime(eventHandle, _calendar_event.until_time, tmpTimeValue); + calendar_record_set_caltime(eventHandle, _calendar_event.until_time, tmpTimeValue); char* tmpStrValue = null; - errorCode = calendar_record_get_str_p(baseEventHandle, _calendar_event.byday, &tmpStrValue); + 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); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); + + 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); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); + + 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); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); + + calendar_record_get_str_p(baseEventHandle, _calendar_event.exdate, &tmpStrValue); errorCode = calendar_record_set_str(eventHandle, _calendar_event.exdate, tmpStrValue); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); if (baseEventId == _INVALID_EVENT_DB_ID) { - errorCode = calendar_record_set_int(eventHandle, _calendar_event.original_event_id, eventInstance.GetOriginalEventId()); + calendar_record_set_int(eventHandle, _calendar_event.original_event_id, eventInstance.GetOriginalEventId()); std::unique_ptr pConvertedRecurrenceId(_StringConverter::CopyToCharArrayN(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(eventInstance.GetStartTime(), eventInstance.IsAllDayEvent()))); errorCode = calendar_record_set_str(eventHandle, _calendar_event.recurrence_id, pConvertedRecurrenceId.get()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed."); int dbIndex = -1; errorCode = calendar_db_insert_record(eventHandle, &dbIndex); @@ -1481,12 +1510,12 @@ _CalendarbookImpl::SearchN(const CalendarbookFilter& filter, unsigned long prope viewSortPropertyId = _CalendarbookFilterImpl::GetViewPropertyId(type, propertySortedBy); ascending = (sortOrder == SORT_ORDER_ASCENDING) ? true : false; - errorCode = calendar_query_set_sort(queryHandle, viewSortPropertyId, ascending); + calendar_query_set_sort(queryHandle, viewSortPropertyId, ascending); } if (filterHandle) { - errorCode = calendar_query_set_filter(queryHandle, filterHandle); + calendar_query_set_filter(queryHandle, filterHandle); } calendar_list_h resultListHandle = null; @@ -1503,21 +1532,21 @@ _CalendarbookImpl::SearchN(const CalendarbookFilter& filter, unsigned long prope { pList.reset(ConvertRecordListN(resultListHandle, _calendar_event)); SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - errorCode = calendar_list_destroy(calendarList.ReleaseHandle(), false); + calendar_list_destroy(calendarList.ReleaseHandle(), false); } break; case CB_FI_TYPE_TODO: { pList.reset(ConvertRecordListN(resultListHandle, _calendar_todo)); SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - errorCode = calendar_list_destroy(calendarList.ReleaseHandle(), false); + calendar_list_destroy(calendarList.ReleaseHandle(), false); } break; case CB_FI_TYPE_CALENDAR: { pList.reset(ConvertRecordListN(resultListHandle, _calendar_book)); SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - errorCode = calendar_list_destroy(calendarList.ReleaseHandle(), false); + calendar_list_destroy(calendarList.ReleaseHandle(), false); } break; case CB_FI_TYPE_ALL_DAY_EVENT_INSTANCE: @@ -1558,7 +1587,7 @@ _CalendarbookImpl::GetMatchedItemCount(const CalendarbookFilter& filter) const if (filterHandle) { - errorCode = calendar_query_set_filter(queryHandle, filterHandle); + calendar_query_set_filter(queryHandle, filterHandle); } int count = _INVALID_COUNT; @@ -1621,17 +1650,17 @@ _CalendarbookImpl::ParseEventsFromVcalendarN(const String& vCalFilePath) SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(calendarListHandle, &count); + calendar_list_get_count(calendarListHandle, &count); - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); for (int i = 0; i < count; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_next(calendarListHandle); char* pUri = null; - errorCode = calendar_record_get_uri_p(tmpRecordHandle, &pUri); + calendar_record_get_uri_p(tmpRecordHandle, &pUri); if (strcmp(pUri, _calendar_event._uri) == 0) { @@ -1643,25 +1672,25 @@ _CalendarbookImpl::ParseEventsFromVcalendarN(const String& vCalFilePath) } else { - errorCode = calendar_list_remove(calendarListHandle, tmpRecordHandle); - errorCode = calendar_record_destroy(tmpRecordHandle, true); + calendar_list_remove(calendarListHandle, tmpRecordHandle); + calendar_record_destroy(tmpRecordHandle, true); } } - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); std::unique_ptr pEnum(pList->GetEnumeratorN()); while (pEnum->MoveNext() == E_SUCCESS) { CalEvent* pTmpEvent = static_cast(pEnum->GetCurrent()); calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); _CalEventImpl::GetInstance(*pTmpEvent)->SetRecordHandle(tmpRecordHandle); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_next(calendarListHandle); } - errorCode = calendar_list_destroy(calendarList.ReleaseHandle(), false); + calendar_list_destroy(calendarList.ReleaseHandle(), false); return pList.release(); } @@ -1718,17 +1747,17 @@ _CalendarbookImpl::ParseTodosFromVcalendarN(const String& vCalFilePath) SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(calendarListHandle, &count); + calendar_list_get_count(calendarListHandle, &count); - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); for (int i = 0; i < count; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_next(calendarListHandle); char* pUri = null; - errorCode = calendar_record_get_uri_p(tmpRecordHandle, &pUri); + calendar_record_get_uri_p(tmpRecordHandle, &pUri); if (strcmp(pUri, _calendar_todo._uri) == 0) { @@ -1740,25 +1769,25 @@ _CalendarbookImpl::ParseTodosFromVcalendarN(const String& vCalFilePath) } else { - errorCode = calendar_list_remove(calendarListHandle, tmpRecordHandle); - errorCode = calendar_record_destroy(tmpRecordHandle, true); + calendar_list_remove(calendarListHandle, tmpRecordHandle); + calendar_record_destroy(tmpRecordHandle, true); } } - errorCode = calendar_list_first(calendarListHandle); + calendar_list_first(calendarListHandle); std::unique_ptr pEnum(pList->GetEnumeratorN()); while (pEnum->MoveNext() == E_SUCCESS) { CalTodo* pTmpTodo = static_cast(pEnum->GetCurrent()); calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); _CalTodoImpl::GetInstance(*pTmpTodo)->SetRecordHandle(tmpRecordHandle); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_next(calendarListHandle); } - errorCode = calendar_list_destroy(calendarList.ReleaseHandle(), false); + calendar_list_destroy(calendarList.ReleaseHandle(), false); return pList.release(); } @@ -1930,10 +1959,13 @@ _CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& star // Condition : End time of the item > start time of filter errorCode = calendar_filter_add_caltime(allDayEventInstanceMainFilterHandle, _calendar_instance_allday_calendar_book.end_time, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, localStartTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : Start time of the item < end time of filter errorCode = calendar_filter_add_operator(allDayEventInstanceMainFilterHandle, CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_caltime(allDayEventInstanceMainFilterHandle, _calendar_instance_allday_calendar_book.start_time, CALENDAR_MATCH_LESS_THAN_OR_EQUAL, localEndTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Create query calendar_query_h allDayEventInstanceQueryHandle = null; @@ -1941,8 +1973,8 @@ _CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& star SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); _CalendarQuery allDayEventInstanceQuery(allDayEventInstanceQueryHandle); - errorCode = calendar_query_set_sort(allDayEventInstanceQueryHandle, _calendar_instance_allday_calendar_book.start_time, true); - errorCode = calendar_query_set_filter(allDayEventInstanceQueryHandle, allDayEventInstanceMainFilterHandle); + calendar_query_set_sort(allDayEventInstanceQueryHandle, _calendar_instance_allday_calendar_book.start_time, true); + calendar_query_set_filter(allDayEventInstanceQueryHandle, allDayEventInstanceMainFilterHandle); int startIndex = (pageNo - 1) * countPerPage; @@ -1962,16 +1994,16 @@ _CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& star SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); int count = 0; - errorCode = calendar_list_get_count(allDayEventInstanceListHandle, &count); + calendar_list_get_count(allDayEventInstanceListHandle, &count); int pageCount = allDayEventInstanceCount / countPerPage; int remainingCount = countPerPage - count; - errorCode = calendar_list_first(allDayEventInstanceListHandle); + calendar_list_first(allDayEventInstanceListHandle); for (int i = 0; i < count; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(allDayEventInstanceListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(allDayEventInstanceListHandle, &tmpRecordHandle); std::unique_ptr pTmpEventInstance(_CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventN(tmpRecordHandle)); SysTryReturn(NID_SCL, pTmpEventInstance != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); @@ -1979,7 +2011,7 @@ _CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& star r = pList->Add(*pTmpEventInstance.release()); SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - errorCode = calendar_list_next(allDayEventInstanceListHandle); + calendar_list_next(allDayEventInstanceListHandle); } if (remainingCount > 0) @@ -1997,12 +2029,16 @@ _CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& star // Condition : End time of the item > start time of filter errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.end_time, CALENDAR_MATCH_GREATER_THAN, startTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : Start time of the item < end time of filter errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_LESS_THAN, endTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_filter(nonAllDayEventInstanceMainFilterHandle, subFilter.GetHandle()); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : Start time of the item = start time of filter AND Start time of the item = end time of filter errorCode = calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &subFilterHandle); @@ -2011,11 +2047,16 @@ _CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& star subFilterHandle = null; errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_EQUAL, startTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_EQUAL, endTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_operator(nonAllDayEventInstanceMainFilterHandle, CALENDAR_FILTER_OPERATOR_OR); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_filter(nonAllDayEventInstanceMainFilterHandle, subFilter.GetHandle()); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Create query calendar_query_h nonAllDayEventInstanceQueryHandle = null; @@ -2023,8 +2064,8 @@ _CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& star SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); _CalendarQuery nonAllDayEventInstanceQuery(nonAllDayEventInstanceQueryHandle); - errorCode = calendar_query_set_sort(nonAllDayEventInstanceQueryHandle, _calendar_instance_normal_calendar_book.start_time, true); - errorCode = calendar_query_set_filter(nonAllDayEventInstanceQueryHandle, nonAllDayEventInstanceMainFilterHandle); + calendar_query_set_sort(nonAllDayEventInstanceQueryHandle, _calendar_instance_normal_calendar_book.start_time, true); + calendar_query_set_filter(nonAllDayEventInstanceQueryHandle, nonAllDayEventInstanceMainFilterHandle); if (remainingCount == countPerPage) { @@ -2042,12 +2083,12 @@ _CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& star _CalendarList nonAllDayEventList(nonAllDayEventInstanceListHandle); count = 0; - errorCode = calendar_list_get_count(nonAllDayEventInstanceListHandle, &count); - errorCode = calendar_list_first(nonAllDayEventInstanceListHandle); + calendar_list_get_count(nonAllDayEventInstanceListHandle, &count); + calendar_list_first(nonAllDayEventInstanceListHandle); for (int i = 0; i < count; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(nonAllDayEventInstanceListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(nonAllDayEventInstanceListHandle, &tmpRecordHandle); std::unique_ptr pTmpEventInstance(_CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventN(tmpRecordHandle)); SysTryReturn(NID_SCL, pTmpEventInstance != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); @@ -2055,7 +2096,7 @@ _CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& star r = pList->Add(*pTmpEventInstance.release()); SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - errorCode = calendar_list_next(nonAllDayEventInstanceListHandle); + calendar_list_next(nonAllDayEventInstanceListHandle); } } @@ -2077,10 +2118,13 @@ _CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime // Condition : End time of the item > start time of filter errorCode = calendar_filter_add_caltime(allDayEventInstanceMainFilterHandle, _calendar_instance_allday_calendar_book.end_time, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, localStartTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : Start time of the item < end time of filter errorCode = calendar_filter_add_operator(allDayEventInstanceMainFilterHandle, CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_caltime(allDayEventInstanceMainFilterHandle, _calendar_instance_allday_calendar_book.start_time, CALENDAR_MATCH_LESS_THAN_OR_EQUAL, localEndTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Create query calendar_query_h allDayEventInstanceQueryHandle = null; @@ -2088,8 +2132,8 @@ _CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); _CalendarQuery allDayEventInstanceQuery(allDayEventInstanceQueryHandle); - errorCode = calendar_query_set_sort(allDayEventInstanceQueryHandle, _calendar_instance_allday_calendar_book.start_time, true); - errorCode = calendar_query_set_filter(allDayEventInstanceQueryHandle, allDayEventInstanceMainFilterHandle); + calendar_query_set_sort(allDayEventInstanceQueryHandle, _calendar_instance_allday_calendar_book.start_time, true); + calendar_query_set_filter(allDayEventInstanceQueryHandle, allDayEventInstanceMainFilterHandle); // Generate event : category map std::unique_ptr< HashMapT > pEventCategoryMap(GenerateEventCategoryMapN()); @@ -2111,16 +2155,16 @@ _CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime int remainingCount = countPerPage; int candidateCount = 0; int count = 0; - errorCode = calendar_list_get_count(allDayEventInstanceListHandle, &count); - errorCode = calendar_list_first(allDayEventInstanceListHandle); + calendar_list_get_count(allDayEventInstanceListHandle, &count); + calendar_list_first(allDayEventInstanceListHandle); for (int i = 0; i < count && remainingCount > 0; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(allDayEventInstanceListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(allDayEventInstanceListHandle, &tmpRecordHandle); int tmpCategory = EVENT_CATEGORY_ALL; int eventId = -1; - errorCode = calendar_record_get_int(tmpRecordHandle, _calendar_instance_allday_calendar_book.event_id, &eventId); + calendar_record_get_int(tmpRecordHandle, _calendar_instance_allday_calendar_book.event_id, &eventId); pEventCategoryMap->GetValue(eventId, tmpCategory); if (tmpCategory == category) @@ -2139,7 +2183,7 @@ _CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime candidateCount++; } - errorCode = calendar_list_next(allDayEventInstanceListHandle); + calendar_list_next(allDayEventInstanceListHandle); } if (remainingCount > 0) @@ -2157,12 +2201,16 @@ _CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime // Condition : End time of the item > start time of filter errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.end_time, CALENDAR_MATCH_GREATER_THAN, startTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : Start time of the item < end time of filter errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_LESS_THAN, endTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_filter(nonAllDayEventInstanceMainFilterHandle, subFilter.GetHandle()); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Condition : Start time of the item = start time of filter AND Start time of the item = end time of filter errorCode = calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &subFilterHandle); @@ -2171,11 +2219,16 @@ _CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime subFilterHandle = null; errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_EQUAL, startTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_AND); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_EQUAL, endTime); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_operator(nonAllDayEventInstanceMainFilterHandle, CALENDAR_FILTER_OPERATOR_OR); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); errorCode = calendar_filter_add_filter(nonAllDayEventInstanceMainFilterHandle, subFilter.GetHandle()); + SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); // Create query calendar_query_h nonAllDayEventInstanceQueryHandle = null; @@ -2183,8 +2236,8 @@ _CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); _CalendarQuery nonAllDayEventInstanceQuery(nonAllDayEventInstanceQueryHandle); - errorCode = calendar_query_set_sort(nonAllDayEventInstanceQueryHandle, _calendar_instance_normal_calendar_book.start_time, true); - errorCode = calendar_query_set_filter(nonAllDayEventInstanceQueryHandle, nonAllDayEventInstanceMainFilterHandle); + calendar_query_set_sort(nonAllDayEventInstanceQueryHandle, _calendar_instance_normal_calendar_book.start_time, true); + calendar_query_set_filter(nonAllDayEventInstanceQueryHandle, nonAllDayEventInstanceMainFilterHandle); if (remainingCount == countPerPage) { @@ -2205,16 +2258,16 @@ _CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime candidateCount = 0; count = 0; - errorCode = calendar_list_get_count(nonAllDayEventInstanceListHandle, &count); - errorCode = calendar_list_first(nonAllDayEventInstanceListHandle); + calendar_list_get_count(nonAllDayEventInstanceListHandle, &count); + calendar_list_first(nonAllDayEventInstanceListHandle); for (int i = 0; i < count && remainingCount > 0; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(nonAllDayEventInstanceListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(nonAllDayEventInstanceListHandle, &tmpRecordHandle); int tmpCategory = EVENT_CATEGORY_ALL; int eventId = -1; - errorCode = calendar_record_get_int(tmpRecordHandle, _calendar_instance_normal_calendar_book.event_id, &eventId); + calendar_record_get_int(tmpRecordHandle, _calendar_instance_normal_calendar_book.event_id, &eventId); pEventCategoryMap->GetValue(eventId, tmpCategory); if (tmpCategory == category) @@ -2233,7 +2286,7 @@ _CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime candidateCount++; } - errorCode = calendar_list_next(nonAllDayEventInstanceListHandle); + calendar_list_next(nonAllDayEventInstanceListHandle); } } @@ -2254,8 +2307,8 @@ _CalendarbookImpl::GenerateEventCategoryMapN(void) const SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); _CalendarQuery query(queryHandle); - errorCode = calendar_query_set_projection(queryHandle, projectionList, _NUMBER_OF_EVENT_CATEGORY_MAP_PROJECTION); - errorCode = calendar_query_set_sort(queryHandle, _calendar_event.id, true); + calendar_query_set_projection(queryHandle, projectionList, _NUMBER_OF_EVENT_CATEGORY_MAP_PROJECTION); + calendar_query_set_sort(queryHandle, _calendar_event.id, true); calendar_list_h calendarListHandle = null; errorCode = calendar_db_get_records_with_query(queryHandle, 0, 0, &calendarListHandle); @@ -2269,24 +2322,24 @@ _CalendarbookImpl::GenerateEventCategoryMapN(void) const SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); int count = 0; - errorCode = calendar_list_get_count(calendarListHandle, &count); - errorCode = calendar_list_first(calendarListHandle); + calendar_list_get_count(calendarListHandle, &count); + calendar_list_first(calendarListHandle); for (int i = 0; i < count; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle); int eventId = -1; char* pCategories = null; - errorCode = calendar_record_get_int(tmpRecordHandle, _calendar_event.id, &eventId); - errorCode = calendar_record_get_str_p(tmpRecordHandle, _calendar_event.categories, &pCategories); + calendar_record_get_int(tmpRecordHandle, _calendar_event.id, &eventId); + calendar_record_get_str_p(tmpRecordHandle, _calendar_event.categories, &pCategories); int category = _CalendarbookUtil::ConvertCSCategoriesToEventCategory(pCategories); pEventCategoryMap->Add(eventId, category); - errorCode = calendar_list_next(calendarListHandle); + calendar_list_next(calendarListHandle); } return pEventCategoryMap.release(); @@ -2304,7 +2357,7 @@ _CalendarbookImpl::GetCalendarItemTypeByCalendarId(RecordId calendarId) const errorCode = calendar_db_get_record(_calendar_book._uri, calendarId, &calendarHandle); SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, CALENDAR_ITEM_TYPE_EVENT_AND_TODO, E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); - errorCode = calendar_record_get_int(calendarHandle, _calendar_book.store_type, &storeType); + calendar_record_get_int(calendarHandle, _calendar_book.store_type, &storeType); if (storeType == (CALENDAR_BOOK_TYPE_EVENT | CALENDAR_BOOK_TYPE_TODO)) { @@ -2442,10 +2495,10 @@ _CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventN(calendar_record_h calendar_time_s startCalendarTime; calendar_time_s endCalendarTime; - errorCode = calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.start_time, &startCalendarTime); - errorCode = calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.end_time, &endCalendarTime); - errorCode = calendar_record_set_caltime(eventHandle, _calendar_event.start_time, startCalendarTime); - errorCode = calendar_record_set_caltime(eventHandle, _calendar_event.end_time, endCalendarTime); + calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.start_time, &startCalendarTime); + calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.end_time, &endCalendarTime); + calendar_record_set_caltime(eventHandle, _calendar_event.start_time, startCalendarTime); + calendar_record_set_caltime(eventHandle, _calendar_event.end_time, endCalendarTime); pEventImpl->SetOriginalCalEventId(originalEventDBId); pEventImpl->SetRecordHandle(eventHandle); @@ -2472,10 +2525,10 @@ _CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventN(calendar_recor calendar_time_s startCalendarTime; calendar_time_s endCalendarTime; - errorCode = calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.start_time, &startCalendarTime); - errorCode = calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.end_time, &endCalendarTime); - errorCode = calendar_record_set_caltime(eventHandle, _calendar_event.start_time, startCalendarTime); - errorCode = calendar_record_set_caltime(eventHandle, _calendar_event.end_time, endCalendarTime); + calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.start_time, &startCalendarTime); + calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.end_time, &endCalendarTime); + calendar_record_set_caltime(eventHandle, _calendar_event.start_time, startCalendarTime); + calendar_record_set_caltime(eventHandle, _calendar_event.end_time, endCalendarTime); pEventImpl->SetOriginalCalEventId(originalEventDBId); pEventImpl->SetRecordHandle(eventHandle); @@ -2486,8 +2539,6 @@ _CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventN(calendar_recor CalEventInstance* _CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventInstanceN(calendar_record_h instanceHandle) { - int errorCode = CALENDAR_ERROR_NONE; - ClearLastResult(); std::unique_ptr pEventInstance(new (std::nothrow) CalEventInstance()); @@ -2495,15 +2546,15 @@ _CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventInstanceN(calendar_ _CalEventInstanceImpl* pEventInstanceImpl = _CalEventInstanceImpl::GetInstance(*pEventInstance.get()); int originalEventDBId = _INVALID_EVENT_DB_ID; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.event_id, &originalEventDBId); + calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.event_id, &originalEventDBId); pEventInstanceImpl->SetOriginalEventId(originalEventDBId); int calendarDBId = _INVALID_CALENDARBOOK_DB_ID; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.calendar_book_id, &calendarDBId); + calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.calendar_book_id, &calendarDBId); pEventInstanceImpl->SetCalendarId(calendarDBId); int srcEventBusyStatus = CALENDAR_EVENT_BUSY_STATUS_FREE; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.busy_status, &srcEventBusyStatus); + calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.busy_status, &srcEventBusyStatus); BusyStatus busyStatus = BUSY_STATUS_FREE; switch (srcEventBusyStatus) { @@ -2527,7 +2578,7 @@ _CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventInstanceN(calendar_ pEventInstanceImpl->SetBusyStatus(busyStatus); int srcEventStatus = CALENDAR_EVENT_STATUS_NONE; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.event_status, &srcEventStatus); + calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.event_status, &srcEventStatus); EventStatus eventStatus = EVENT_STATUS_NONE; switch (srcEventStatus) { @@ -2550,7 +2601,7 @@ _CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventInstanceN(calendar_ pEventInstanceImpl->SetStatus(eventStatus); int srcPriority = CALENDAR_EVENT_PRIORITY_NORMAL; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.priority, &srcPriority); + calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.priority, &srcPriority); EventPriority priority = EVENT_PRIORITY_NORMAL; switch (srcPriority) { @@ -2572,7 +2623,7 @@ _CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventInstanceN(calendar_ pEventInstanceImpl->SetPriority(priority); int srcSensitivity = CALENDAR_SENSITIVITY_PUBLIC; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.sensitivity, &srcSensitivity); + calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.sensitivity, &srcSensitivity); RecordSensitivity sensitivity = SENSITIVITY_PUBLIC; switch (srcSensitivity) { @@ -2593,36 +2644,36 @@ _CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventInstanceN(calendar_ calendar_time_s startCalendarTime; DateTime tmpStartTime; - errorCode = calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.start_time, &startCalendarTime); + calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.start_time, &startCalendarTime); tmpStartTime.SetValue(startCalendarTime.time.date.year, startCalendarTime.time.date.month, startCalendarTime.time.date.mday); pEventInstanceImpl->SetStartTime(tmpStartTime); calendar_time_s endCalendarTime; DateTime tmpEndTime; - errorCode = calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.end_time, &endCalendarTime); + calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.end_time, &endCalendarTime); tmpEndTime.SetValue(endCalendarTime.time.date.year, endCalendarTime.time.date.month, endCalendarTime.time.date.mday); pEventInstanceImpl->SetEndTime(tmpEndTime); pEventInstanceImpl->SetAllDayEvent(true); int isRecurring = 0; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.has_rrule, &isRecurring); + calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.has_rrule, &isRecurring); pEventInstanceImpl->SetRecurring(isRecurring); int hasReminder = 0; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.has_alarm, &hasReminder); + calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.has_alarm, &hasReminder); pEventInstanceImpl->SetHasReminder(hasReminder); char* pSubject = null; - errorCode = calendar_record_get_str_p(instanceHandle, _calendar_instance_allday_calendar_book.summary, &pSubject); + calendar_record_get_str_p(instanceHandle, _calendar_instance_allday_calendar_book.summary, &pSubject); pEventInstanceImpl->SetSubject(pSubject); char* pDescription = null; - errorCode = calendar_record_get_str_p(instanceHandle, _calendar_instance_allday_calendar_book.description, &pDescription); + calendar_record_get_str_p(instanceHandle, _calendar_instance_allday_calendar_book.description, &pDescription); pEventInstanceImpl->SetDescription(pDescription); char* pLocation = null; - errorCode = calendar_record_get_str_p(instanceHandle, _calendar_instance_allday_calendar_book.location, &pLocation); + calendar_record_get_str_p(instanceHandle, _calendar_instance_allday_calendar_book.location, &pLocation); pEventInstanceImpl->SetLocation(pLocation); return pEventInstance.release(); @@ -2631,8 +2682,6 @@ _CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventInstanceN(calendar_ CalEventInstance* _CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(calendar_record_h instanceHandle) { - int errorCode = CALENDAR_ERROR_NONE; - ClearLastResult(); std::unique_ptr pEventInstance(new (std::nothrow) CalEventInstance()); @@ -2640,15 +2689,15 @@ _CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(calend _CalEventInstanceImpl* pEventInstanceImpl = _CalEventInstanceImpl::GetInstance(*pEventInstance.get()); int originalEventDBId = _INVALID_EVENT_DB_ID; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.event_id, &originalEventDBId); + calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.event_id, &originalEventDBId); pEventInstanceImpl->SetOriginalEventId(originalEventDBId); int calendarDBId = _INVALID_CALENDARBOOK_DB_ID; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.calendar_book_id, &calendarDBId); + calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.calendar_book_id, &calendarDBId); pEventInstanceImpl->SetCalendarId(calendarDBId); int srcEventBusyStatus = CALENDAR_EVENT_BUSY_STATUS_FREE; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.busy_status, &srcEventBusyStatus); + calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.busy_status, &srcEventBusyStatus); BusyStatus busyStatus = BUSY_STATUS_FREE; switch (srcEventBusyStatus) { @@ -2672,7 +2721,7 @@ _CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(calend pEventInstanceImpl->SetBusyStatus(busyStatus); int srcEventStatus = CALENDAR_EVENT_STATUS_NONE; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.event_status, &srcEventStatus); + calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.event_status, &srcEventStatus); EventStatus eventStatus = EVENT_STATUS_NONE; switch (srcEventStatus) @@ -2696,7 +2745,7 @@ _CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(calend pEventInstanceImpl->SetStatus(eventStatus); int srcPriority = CALENDAR_EVENT_PRIORITY_NORMAL; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.priority, &srcPriority); + calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.priority, &srcPriority); EventPriority priority = EVENT_PRIORITY_NORMAL; switch (srcPriority) { @@ -2718,7 +2767,7 @@ _CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(calend pEventInstanceImpl->SetPriority(priority); int srcSensitivity = CALENDAR_SENSITIVITY_PUBLIC; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.sensitivity, &srcSensitivity); + calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.sensitivity, &srcSensitivity); RecordSensitivity sensitivity = SENSITIVITY_PUBLIC; switch (srcSensitivity) { @@ -2739,36 +2788,36 @@ _CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(calend calendar_time_s startCalendarTime; DateTime tmpStartTime; - errorCode = calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.start_time, &startCalendarTime); + calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.start_time, &startCalendarTime); tmpStartTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(startCalendarTime.time.utime); pEventInstanceImpl->SetStartTime(tmpStartTime); calendar_time_s endCalendarTime; DateTime tmpEndTime; - errorCode = calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.end_time, &endCalendarTime); + calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.end_time, &endCalendarTime); tmpEndTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(endCalendarTime.time.utime); pEventInstanceImpl->SetEndTime(tmpEndTime); pEventInstanceImpl->SetAllDayEvent(false); int isRecurring = 0; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.has_rrule, &isRecurring); + calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.has_rrule, &isRecurring); pEventInstanceImpl->SetRecurring(isRecurring); int hasReminder = 0; - errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.has_alarm, &hasReminder); + calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.has_alarm, &hasReminder); pEventInstanceImpl->SetHasReminder(hasReminder); char* pSubject = null; - errorCode = calendar_record_get_str_p(instanceHandle, _calendar_instance_normal_calendar_book.summary, &pSubject); + calendar_record_get_str_p(instanceHandle, _calendar_instance_normal_calendar_book.summary, &pSubject); pEventInstanceImpl->SetSubject(pSubject); char* pDescription = null; - errorCode = calendar_record_get_str_p(instanceHandle, _calendar_instance_normal_calendar_book.description, &pDescription); + calendar_record_get_str_p(instanceHandle, _calendar_instance_normal_calendar_book.description, &pDescription); pEventInstanceImpl->SetDescription(pDescription); char* pLocation = null; - errorCode = calendar_record_get_str_p(instanceHandle, _calendar_instance_normal_calendar_book.location, &pLocation); + calendar_record_get_str_p(instanceHandle, _calendar_instance_normal_calendar_book.location, &pLocation); pEventInstanceImpl->SetLocation(pLocation); return pEventInstance.release(); @@ -2777,8 +2826,6 @@ _CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(calend CalEventChangeInfo* _CalendarbookImpl::ConvertModifiedEventToCalEventChangeInfoN(calendar_record_h modifiedEventHandle) { - int errorCode = CALENDAR_ERROR_NONE; - ClearLastResult(); std::unique_ptr pEventChangeInfo(new (std::nothrow) CalEventChangeInfo()); @@ -2786,15 +2833,15 @@ _CalendarbookImpl::ConvertModifiedEventToCalEventChangeInfoN(calendar_record_h m _CalEventChangeInfoImpl* pEventChangeInfoImpl = _CalEventChangeInfoImpl::GetInstance(*pEventChangeInfo.get()); int eventId = 0; - errorCode = calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.id, &eventId); + calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.id, &eventId); pEventChangeInfoImpl->SetEventId(eventId); int calendarbookId = 0; - errorCode = calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.calendar_book_id, &calendarbookId); + calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.calendar_book_id, &calendarbookId); pEventChangeInfoImpl->SetCalendarId(calendarbookId); int modifiedStatus = CALENDAR_RECORD_MODIFIED_STATUS_INSERTED; - errorCode = calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.modified_status, &modifiedStatus); + calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.modified_status, &modifiedStatus); RecordChangeType recordChangeType = RECORD_CHANGE_TYPE_ADDED; switch (modifiedStatus) { @@ -2814,7 +2861,7 @@ _CalendarbookImpl::ConvertModifiedEventToCalEventChangeInfoN(calendar_record_h m pEventChangeInfoImpl->SetChangeType(recordChangeType); int version = 0; - errorCode = calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.version, &version); + calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.version, &version); pEventChangeInfoImpl->SetVersion(version); return pEventChangeInfo.release(); @@ -2823,8 +2870,6 @@ _CalendarbookImpl::ConvertModifiedEventToCalEventChangeInfoN(calendar_record_h m CalTodoChangeInfo* _CalendarbookImpl::ConvertModifiedTodoToCalTodoChangeInfoN(calendar_record_h modifiedTodoHandle) { - int errorCode = CALENDAR_ERROR_NONE; - ClearLastResult(); std::unique_ptr pTodoChangeInfo(new (std::nothrow) CalTodoChangeInfo()); @@ -2832,15 +2877,15 @@ _CalendarbookImpl::ConvertModifiedTodoToCalTodoChangeInfoN(calendar_record_h mod _CalTodoChangeInfoImpl* pTodoChangeInfoImpl = _CalTodoChangeInfoImpl::GetInstance(*pTodoChangeInfo.get()); int todoId = 0; - errorCode = calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.id, &todoId); + calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.id, &todoId); pTodoChangeInfoImpl->SetTodoId(todoId); int calendarbookId = 0; - errorCode = calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.calendar_book_id, &calendarbookId); + calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.calendar_book_id, &calendarbookId); pTodoChangeInfoImpl->SetCalendarId(calendarbookId); int modifiedStatus = CALENDAR_RECORD_MODIFIED_STATUS_INSERTED; - errorCode = calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.modified_status, &modifiedStatus); + calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.modified_status, &modifiedStatus); RecordChangeType recordChangeType = RECORD_CHANGE_TYPE_ADDED; switch (modifiedStatus) @@ -2861,7 +2906,7 @@ _CalendarbookImpl::ConvertModifiedTodoToCalTodoChangeInfoN(calendar_record_h mod pTodoChangeInfoImpl->SetChangeType(recordChangeType); int version = 0; - errorCode = calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.version, &version); + calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.version, &version); pTodoChangeInfoImpl->SetVersion(version); return pTodoChangeInfo.release(); @@ -2871,7 +2916,6 @@ template IList* _CalendarbookImpl::ConvertRecordListN(calendar_list_h resultListHandle, RecordView recordView) { - int errorCode = CALENDAR_ERROR_NONE; result r = E_SUCCESS; std::unique_ptr pList(new (std::nothrow) ArrayList()); @@ -2880,7 +2924,7 @@ _CalendarbookImpl::ConvertRecordListN(calendar_list_h resultListHandle, RecordVi SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(resultListHandle, &count); + calendar_list_get_count(resultListHandle, &count); for (int i = 0; i < count; i++) { @@ -2891,21 +2935,21 @@ _CalendarbookImpl::ConvertRecordListN(calendar_list_h resultListHandle, RecordVi SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); } - errorCode = calendar_list_first(resultListHandle); + calendar_list_first(resultListHandle); std::unique_ptr pEnum(pList->GetEnumeratorN()); while (pEnum->MoveNext() == E_SUCCESS) { RecordType* pTmpRecord = static_cast(pEnum->GetCurrent()); calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(resultListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(resultListHandle, &tmpRecordHandle); RecordTypeImpl::GetInstance(*pTmpRecord)->SetRecordHandle(tmpRecordHandle); int dbIndex = -1; - errorCode = calendar_record_get_int(tmpRecordHandle, recordView.id, &dbIndex); + calendar_record_get_int(tmpRecordHandle, recordView.id, &dbIndex); _RecordImpl::GetInstance(*pTmpRecord)->SetRecordId(dbIndex); - errorCode = calendar_list_next(resultListHandle); + calendar_list_next(resultListHandle); } return pList.release(); @@ -2914,7 +2958,6 @@ _CalendarbookImpl::ConvertRecordListN(calendar_list_h resultListHandle, RecordVi IList* _CalendarbookImpl::ConvertEventInstanceListN(calendar_list_h resultListHandle, bool isAllDay) { - int errorCode = CALENDAR_ERROR_NONE; result r = E_SUCCESS; std::unique_ptr pList(new (std::nothrow) ArrayList()); @@ -2923,12 +2966,12 @@ _CalendarbookImpl::ConvertEventInstanceListN(calendar_list_h resultListHandle, b SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); int count = 0; - errorCode = calendar_list_get_count(resultListHandle, &count); - errorCode = calendar_list_first(resultListHandle); + calendar_list_get_count(resultListHandle, &count); + calendar_list_first(resultListHandle); for (int i = 0; i < count; i++) { calendar_record_h tmpRecordHandle = null; - errorCode = calendar_list_get_current_record_p(resultListHandle, &tmpRecordHandle); + calendar_list_get_current_record_p(resultListHandle, &tmpRecordHandle); std::unique_ptr pTmpEventInstance; @@ -2946,7 +2989,7 @@ _CalendarbookImpl::ConvertEventInstanceListN(calendar_list_h resultListHandle, b r = pList->Add(*pTmpEventInstance.release()); SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - errorCode = calendar_list_next(resultListHandle); + calendar_list_next(resultListHandle); } return pList.release(); diff --git a/src/FScl_CalendarbookRecordRetrivalThread.cpp b/src/FScl_CalendarbookRecordRetrivalThread.cpp index 6cebf3d..7f0e2b8 100644 --- a/src/FScl_CalendarbookRecordRetrivalThread.cpp +++ b/src/FScl_CalendarbookRecordRetrivalThread.cpp @@ -112,12 +112,12 @@ CATCH: pEventArg.reset(new (std::nothrow) _CalendarbookRecordRetrivalEventArg(__requestId, null, r)); if (pEventArg != null) { - r = __pEvent->Fire(*pEventArg); + __pEvent->Fire(*pEventArg); } __pEvent.reset(null); } - r = _CalendarbookDbConnector::Disconnect(); + _CalendarbookDbConnector::Disconnect(); return null; } diff --git a/src/FScl_CalendarbookUtil.cpp b/src/FScl_CalendarbookUtil.cpp index 741f0ca..4c6ff28 100644 --- a/src/FScl_CalendarbookUtil.cpp +++ b/src/FScl_CalendarbookUtil.cpp @@ -184,10 +184,8 @@ _CalendarbookUtil::ConvertCharArrayToByteBufferN(const char* pCharArray) result _CalendarbookUtil::ConvertEventAlarmsToReminderList(calendar_record_h calendarRecordHandle, ArrayList& reminderList) { - int errorCode = CALENDAR_ERROR_NONE; - unsigned int reminderCount = 0; - errorCode = calendar_record_get_child_record_count(calendarRecordHandle, _calendar_event.calendar_alarm, &reminderCount); + calendar_record_get_child_record_count(calendarRecordHandle, _calendar_event.calendar_alarm, &reminderCount); if (reminderCount == 0) { @@ -203,11 +201,11 @@ _CalendarbookUtil::ConvertEventAlarmsToReminderList(calendar_record_h calendarRe long long tmpAlarmTime = 0; char* pTmpAlarmTone = null; - errorCode = calendar_record_get_child_record_at_p(calendarRecordHandle, _calendar_event.calendar_alarm, i, &tmpAlarmHandle); - errorCode = calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick_unit, &tmpAlarmTickUnit); - errorCode = calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick, &tmpAlarmTick); - errorCode = calendar_record_get_lli(tmpAlarmHandle, _calendar_alarm.time, &tmpAlarmTime); - errorCode = calendar_record_get_str_p(tmpAlarmHandle, _calendar_alarm.tone, &pTmpAlarmTone); + calendar_record_get_child_record_at_p(calendarRecordHandle, _calendar_event.calendar_alarm, i, &tmpAlarmHandle); + calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick_unit, &tmpAlarmTickUnit); + calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick, &tmpAlarmTick); + calendar_record_get_lli(tmpAlarmHandle, _calendar_alarm.time, &tmpAlarmTime); + calendar_record_get_str_p(tmpAlarmHandle, _calendar_alarm.tone, &pTmpAlarmTone); std::unique_ptr pReminder(new (std::nothrow) Reminder()); SysTryReturnResult(NID_SCL, pReminder != null, E_OUT_OF_MEMORY, "Memory allocation failed."); @@ -233,7 +231,7 @@ _CalendarbookUtil::ConvertEventAlarmsToReminderList(calendar_record_h calendarRe calendar_time_s startCalendarTime; DateTime tmpStartTime; - errorCode = calendar_record_get_caltime(calendarRecordHandle, _calendar_event.start_time, &startCalendarTime); + calendar_record_get_caltime(calendarRecordHandle, _calendar_event.start_time, &startCalendarTime); if (startCalendarTime.type == CALENDAR_TIME_UTIME) { tmpStartTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(startCalendarTime.time.utime); @@ -268,10 +266,8 @@ _CalendarbookUtil::ConvertEventAlarmsToReminderList(calendar_record_h calendarRe result _CalendarbookUtil::ConvertTodoAlarmsToReminderList(calendar_record_h calendarRecordHandle, ArrayList& reminderList) { - int errorCode = CALENDAR_ERROR_NONE; - unsigned int reminderCount = 0; - errorCode = calendar_record_get_child_record_count(calendarRecordHandle, _calendar_todo.calendar_alarm, &reminderCount); + calendar_record_get_child_record_count(calendarRecordHandle, _calendar_todo.calendar_alarm, &reminderCount); if (reminderCount == 0) { @@ -287,11 +283,11 @@ _CalendarbookUtil::ConvertTodoAlarmsToReminderList(calendar_record_h calendarRec long long tmpAlarmTime = 0; char* pTmpAlarmTone = null; - errorCode = calendar_record_get_child_record_at_p(calendarRecordHandle, _calendar_todo.calendar_alarm, i, &tmpAlarmHandle); - errorCode = calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick_unit, &tmpAlarmTickUnit); - errorCode = calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick, &tmpAlarmTick); - errorCode = calendar_record_get_lli(tmpAlarmHandle, _calendar_alarm.time, &tmpAlarmTime); - errorCode = calendar_record_get_str_p(tmpAlarmHandle, _calendar_alarm.tone, &pTmpAlarmTone); + calendar_record_get_child_record_at_p(calendarRecordHandle, _calendar_todo.calendar_alarm, i, &tmpAlarmHandle); + calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick_unit, &tmpAlarmTickUnit); + calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick, &tmpAlarmTick); + calendar_record_get_lli(tmpAlarmHandle, _calendar_alarm.time, &tmpAlarmTime); + calendar_record_get_str_p(tmpAlarmHandle, _calendar_alarm.tone, &pTmpAlarmTone); std::unique_ptr pReminder(new (std::nothrow) Reminder()); SysTryReturnResult(NID_SCL, pReminder != null, E_OUT_OF_MEMORY, "Memory allocation failed."); @@ -317,7 +313,7 @@ _CalendarbookUtil::ConvertTodoAlarmsToReminderList(calendar_record_h calendarRec calendar_time_s startCalendarTime; DateTime tmpStartTime; - errorCode = calendar_record_get_caltime(calendarRecordHandle, _calendar_todo.start_time, &startCalendarTime); + calendar_record_get_caltime(calendarRecordHandle, _calendar_todo.start_time, &startCalendarTime); if (startCalendarTime.type == CALENDAR_TIME_UTIME) { tmpStartTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(startCalendarTime.time.utime); @@ -393,8 +389,11 @@ _CalendarbookUtil::ConvertRRuleDateTimeStringToDateTime(const String& dateTimeSt , E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of Z is wrong r = dateTimeString.SubString(0, _CALENDARBOOK_DATE_VALUE_STRING_LENGTH, dateValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); r = dateTimeString.SubString(_CALENDARBOOK_DATE_VALUE_STRING_LENGTH + 1 , _CALENDARBOOK_TIME_VALUE_STRING_LENGTH, timeValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + isDate = false; } else if (dateTimeString.GetLength() > _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH) // including timezone ID @@ -415,8 +414,10 @@ _CalendarbookUtil::ConvertRRuleDateTimeStringToDateTime(const String& dateTimeSt dateValueIndex += 1; r = dateTimeString.SubString(dateValueIndex, _CALENDARBOOK_DATE_VALUE_STRING_LENGTH, dateValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); r = dateTimeString.SubString(dateValueIndex +_CALENDARBOOK_DATE_VALUE_STRING_LENGTH + 1 , _CALENDARBOOK_TIME_VALUE_STRING_LENGTH, timeValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); r = Tizen::Locales::TimeZone::GetTimeZone(timeZoneId, timeZone); SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // not supported timezone ID @@ -488,46 +489,45 @@ _CalendarbookUtil::ConvertRRuleDateTimeStringToDateTime(const String& dateTimeSt String _CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(const Tizen::Base::DateTime& dateTime, bool isDate) { - result r = E_SUCCESS; String exdateString; - r = exdateString.Append(dateTime.GetYear()); + exdateString.Append(dateTime.GetYear()); if (dateTime.GetMonth() < 10) { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + exdateString.Append(_CALENDARBOOK_ZERO_STRING); } - r = exdateString.Append(dateTime.GetMonth()); + exdateString.Append(dateTime.GetMonth()); if (dateTime.GetDay() < 10) { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + exdateString.Append(_CALENDARBOOK_ZERO_STRING); } - r = exdateString.Append(dateTime.GetDay()); + exdateString.Append(dateTime.GetDay()); if (!isDate) { - r = exdateString.Append(_CALENDARBOOK_TIME_PREFIX); + exdateString.Append(_CALENDARBOOK_TIME_PREFIX); if (dateTime.GetHour() < 10) { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + exdateString.Append(_CALENDARBOOK_ZERO_STRING); } - r = exdateString.Append(dateTime.GetHour()); + exdateString.Append(dateTime.GetHour()); if (dateTime.GetMinute() < 10) { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + exdateString.Append(_CALENDARBOOK_ZERO_STRING); } - r = exdateString.Append(dateTime.GetMinute()); + exdateString.Append(dateTime.GetMinute()); if (dateTime.GetSecond() < 10) { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + exdateString.Append(_CALENDARBOOK_ZERO_STRING); } - r = exdateString.Append(dateTime.GetSecond()); + exdateString.Append(dateTime.GetSecond()); - r = exdateString.Append(_CALENDARBOOK_UTC_SUFFIX); + exdateString.Append(_CALENDARBOOK_UTC_SUFFIX); } return exdateString; -- 2.7.4