* This file contains definitions of @e _CalendarImpl class.
*/
+#include <FBaseInteger.h>
#include <FBaseString.h>
#include <FBaseSysLog.h>
#include <FBaseUtilStringTokenizer.h>
-#include <FBaseInteger.h>
-#include <FSclCalendar.h>
#include <FBase_StringConverter.h>
+#include <FSclCalendar.h>
+#include "FScl_CalendarbookDbConnector.h"
#include "FScl_CalendarImpl.h"
#include "FScl_RecordImpl.h"
-#include "FScl_CalendarbookDbConnector.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Utility;
_CalendarImpl::_CalendarImpl(CalendarItemType itemType)
{
- int errorCode = CALENDAR_ERROR_NONE;
- calendar_record_h calendarHandle = null;
-
result r = _CalendarbookDbConnector::Connect();
- SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.");
+ SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
- 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.");
+ calendar_record_h calendarHandle = null;
+ int errorCode = calendar_record_create(_calendar_book._uri, &calendarHandle);
+ SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- 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);
_CalendarImpl::_CalendarImpl(const _CalendarImpl& rhs)
{
- int errorCode = CALENDAR_ERROR_NONE;
- calendar_record_h calendarHandle = null;
-
result r = _CalendarbookDbConnector::Connect();
- SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.");
+ SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
- errorCode = calendar_record_clone(rhs.__calendarRecord.GetHandle(), &calendarHandle);
- SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ calendar_record_h calendarHandle = null;
+ int errorCode = calendar_record_clone(rhs.__calendarRecord.GetHandle(), &calendarHandle);
+ SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__calendarRecord.ResetHandle(calendarHandle);
}
_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.");
+ SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
}
_CalendarImpl&
return *this;
}
- int errorCode = CALENDAR_ERROR_NONE;
calendar_record_h calendarHandle = null;
- errorCode = calendar_record_clone(rhs.__calendarRecord.GetHandle(), &calendarHandle);
- SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ int errorCode = calendar_record_clone(rhs.__calendarRecord.GetHandle(), &calendarHandle);
+ SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__calendarRecord.ResetHandle(calendarHandle);
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);
}
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)
{
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;
}
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)
{
return E_DATA_NOT_FOUND;
}
- result r = E_SUCCESS;
-
int tmpRed = 0;
int tmpGreen = 0;
int tmpBlue = 0;
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;
_CalendarImpl::SetName(const String& name)
{
std::unique_ptr<char[]> pConvertedName(_StringConverter::CopyToCharArrayN(name));
- SysTryReturnVoidResult(NID_SCL, pConvertedName != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ SysTryReturnVoidResult(NID_SCL, pConvertedName != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- int errorCode = CALENDAR_ERROR_NONE;
- errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.name, pConvertedName.get());
+ int errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.name, pConvertedName.get());
+ SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
}
void
color.Append(255); // alpha
std::unique_ptr<char[]> pConvertedColor(_StringConverter::CopyToCharArrayN(color));
- SysTryReturnVoidResult(NID_SCL, pConvertedColor != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ SysTryReturnVoidResult(NID_SCL, pConvertedColor != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- int errorCode = CALENDAR_ERROR_NONE;
- errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.color, pConvertedColor.get());
+ int errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.color, pConvertedColor.get());
+ SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
}
void
_CalendarImpl::ClearColor(void)
{
- String color;
-
- std::unique_ptr<char[]> pConvertedColor(_StringConverter::CopyToCharArrayN(color));
- SysTryReturnVoidResult(NID_SCL, pConvertedColor != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
- int errorCode = CALENDAR_ERROR_NONE;
- errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.color, pConvertedColor.get());
+ int errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.color, null);
+ SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
}
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