#include <FBaseLongLong.h>
#include <FBaseDateTime.h>
#include <FBaseString.h>
+#include <FBaseUtilStringTokenizer.h>
#include <FBaseColHashMap.h>
#include <FBaseColAllElementsDeleter.h>
using namespace Tizen::App;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
-static const char* REMINDER_CB_KEY_ID = "id";
-static const char* REMINDER_CB_KEY_TYPE = "type";
-static const char* REMINDER_CB_KEY_TIME = "time";
-static const char* REMINDER_CB_KEY_TICK = "tick";
-static const char* REMINDER_CB_KEY_UNIT = "unit";
+static const wchar_t* REMINDER_CB_KEY_ID = L"id";
+static const wchar_t* REMINDER_CB_KEY_TYPE = L"type";
+static const wchar_t* REMINDER_CB_KEY_TIME = L"time";
+static const wchar_t* REMINDER_CB_KEY_TICK = L"tick";
+static const wchar_t* REMINDER_CB_KEY_UNIT = L"unit";
-static const char* REMINDER_CB_VALUE_TYPE_EVENT = "1";
-static const char* REMINDER_CB_VALUE_TYPE_TODO = "2";
+static const wchar_t* REMINDER_CB_VALUE_TYPE_EVENT = L"1";
+static const wchar_t* REMINDER_CB_VALUE_TYPE_TODO = L"2";
static const wchar_t* REMINDER_ARG_KEY_RECORD_ID = L"recordid";
static const wchar_t* REMINDER_ARG_KEY_TYPE = L"recordtype";
}
void
-_CalendarConditionHandler::ReminderCallback(bundle* pBundle, void* pUserData)
+_CalendarConditionHandler::ReminderCallback(const char *pArg, void* pUserData)
{
_AppLaunchCondition* pAppLaunchCondition = static_cast<_AppLaunchCondition*>(pUserData);
SysTryReturnVoidResult(NID_APP, pAppLaunchCondition != null, E_INVALID_STATE, "[E_INVALID_STATE] pUserData should NOT be null.");
_CalendarConditionHandler* pHandler = dynamic_cast<_CalendarConditionHandler*>(pAppLaunchCondition->GetUserData());
SysTryReturnVoidResult(NID_APP, pHandler != null, E_INVALID_STATE, "user data is null");
- SysTryReturnVoidResult(NID_APP, pBundle != null, E_INVALID_STATE, "[E_INVALID_STATE] pBundle should NOT be null.");
+ SysTryReturnVoidResult(NID_APP, pArg != null, E_INVALID_STATE, "[E_INVALID_STATE] pArg should NOT be null.");
+
+ SysLog(NID_APP, "Reminder callback is called. arg : %s", pArg);
std::unique_ptr<HashMap, AllElementsDeleter> pResultMap(new (std::nothrow) HashMap());
SysTryReturnVoidResult(NID_APP, pResultMap != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
SysTryReturnVoidResult(NID_APP, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
// get values
- const char* pStrRecordId = bundle_get_val(pBundle, REMINDER_CB_KEY_ID);
- SysTryReturnVoidResult(NID_APP, pStrRecordId != null, E_INVALID_STATE, "[E_INVALID_STATE] id should NOT be null.");
+ String strRecordId;
+ String strTime;
+ String strTick;
+ String strUnit;
+ String strType;
- const char* pStrType = bundle_get_val(pBundle, REMINDER_CB_KEY_TYPE);
- SysTryReturnVoidResult(NID_APP, pStrType != null, E_INVALID_STATE, "[E_INVALID_STATE] type should NOT be null.");
+ String strArg(pArg);
+ String delim(L"&=");
- const char* pStrTime = bundle_get_val(pBundle, REMINDER_CB_KEY_TIME);
- SysTryReturnVoidResult(NID_APP, pStrTime != null, E_INVALID_STATE, "[E_INVALID_STATE] time should NOT be null.");
+ StringTokenizer strTok(strArg, delim);
- const char* pStrTick = bundle_get_val(pBundle, REMINDER_CB_KEY_TICK);
- SysTryReturnVoidResult(NID_APP, pStrTick != null, E_INVALID_STATE, "[E_INVALID_STATE] tick should NOT be null.");
+ int count = strTok.GetTokenCount();
+ SysTryReturnVoidResult(NID_APP, count == 10, E_INVALID_STATE, "[E_INVALID_STATE] pArg should have 5 key-value pairs.");
- const char* pStrUnit = bundle_get_val(pBundle, REMINDER_CB_KEY_UNIT);
- SysTryReturnVoidResult(NID_APP, pStrUnit != null, E_INVALID_STATE, "[E_INVALID_STATE] unit should NOT be null.");
+ String token;
+ while (strTok.HasMoreTokens())
+ {
+ strTok.GetNextToken(token);
+
+ if (token == REMINDER_CB_KEY_ID)
+ {
+ strTok.GetNextToken(strRecordId);
+ }
+ else if (token == REMINDER_CB_KEY_TIME)
+ {
+ strTok.GetNextToken(strTime);
+ }
+ else if (token == REMINDER_CB_KEY_TICK)
+ {
+ strTok.GetNextToken(strTick);
+ }
+ else if (token == REMINDER_CB_KEY_UNIT)
+ {
+ strTok.GetNextToken(strUnit);
+ }
+ else if (token == REMINDER_CB_KEY_TYPE)
+ {
+ strTok.GetNextToken(strType);
+ }
+ else
+ {
+ SysLog(NID_APP, "This token is illegal. : %S", token.GetPointer());
+ strTok.GetNextToken(token);
+ continue;
+ }
+ }
- SysLog(NID_APP, "Reminder callback is called. id : %s, type : %s, time : %s, tick : %s, unit : %s", pStrRecordId, pStrType, pStrTime, pStrTick, pStrUnit);
+ SysTryReturnVoidResult(NID_APP, !strRecordId.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] id should NOT be null.");
+ SysTryReturnVoidResult(NID_APP, !strType.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] type should NOT be null.");
+ SysTryReturnVoidResult(NID_APP, !strTime.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] time should NOT be null.");
+ SysTryReturnVoidResult(NID_APP, !strTick.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] tick should NOT be null.");
+ SysTryReturnVoidResult(NID_APP, !strUnit.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] unit should NOT be null.");
// convert
std::unique_ptr<String> pRecordType;
- if (strcmp(pStrType, REMINDER_CB_VALUE_TYPE_EVENT) == 0)
+ if (strType == REMINDER_CB_VALUE_TYPE_EVENT)
{
pRecordType.reset(new (std::nothrow) String(REMINDER_ARG_VALUE_TYPE_EVENT));
}
- else if (strcmp(pStrType, REMINDER_CB_VALUE_TYPE_TODO) == 0)
+ else if (strType == REMINDER_CB_VALUE_TYPE_TODO)
{
pRecordType.reset(new (std::nothrow) String(REMINDER_ARG_VALUE_TYPE_TODO));
}
int unit = 0;
- r = Integer::Parse(pStrUnit, unit);
+ r = Integer::Parse(strUnit, unit);
int offset = 0;
- r = Integer::Parse(pStrTick, offset);
+ r = Integer::Parse(strTick, offset);
std::unique_ptr<String> pReminderUnit;
switch (unit)
pReminderOffset->Append(offset);
long long time = 0;
- r = LongLong::Parse(pStrTime, time);
+ r = LongLong::Parse(strTime, time);
std::unique_ptr<String> pTime(new (std::nothrow) String(ConvertEpochTimeToDateTime(time).ToString()));
- r = pResultMap->Add(new String(REMINDER_ARG_KEY_RECORD_ID), new String(pStrRecordId));
+ r = pResultMap->Add(new String(REMINDER_ARG_KEY_RECORD_ID), new (std::nothrow) String(strRecordId));
SysTryReturnVoidResult(NID_APP, r == E_SUCCESS, r, "[%s] Failed to add id to the hash map.", GetErrorMessage(r));
r = pResultMap->Add(new String(REMINDER_ARG_KEY_TYPE), pRecordType.release());