// call for callbacks
// ptr to member function
+ (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
+
+ std::unique_ptr<char[], charDeleter> pOperation(null);
+ char* pBuf = null;
+
+ int errVal = service_get_operation(service, &pBuf);
+ pOperation.reset(pBuf);
+
+ if((errVal == SERVICE_ERROR_NONE) && (!strcmp((const char*)pOperation.get(), "osp.operation.ALARM")))
+ {
+ std::unique_ptr<char[], charDeleter> pAlarmId(null);
+ char* pBuf = null;
+
+ errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pBuf);
+ pAlarmId.reset(pBuf);
+ SysTryReturnVoidResult(NID_SYS, errVal == SERVICE_ERROR_NONE, E_SYSTEM, "It is failed to get reserved alarm id.");
+ int alarmId = atoi((const char*)pAlarmId.get());
+
+ _AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
+ pAlarmManager->OnAlarmExpired(alarmId);
+
+ return;
+ }
}
pAppImpl->__pIAppImpl->OnService(service, initialLaunch);
alarm_cancel_all();
}
-int alarm_callback(alarm_id_t alarmId, void *user_param)
-{
- _AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
- pAlarmManager->OnAlarmExpired((int)alarmId);
- return 0;
-}
-
-result
-_AlarmManager::Construct(void)
-{
- int errorCode;
- Tizen::App::App* pApp = null;
- pApp = Tizen::App::App::GetInstance();
- String appId = pApp->GetAppId();
- std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
-
- errorCode = alarmmgr_init(pAppId.get());
- SysTryReturnResult(NID_SYS, errorCode == ALARMMGR_RESULT_SUCCESS, E_SYSTEM, "It is failed to init alarmmgr. error [%d]", errorCode);
- errorCode = alarmmgr_set_cb(alarm_callback, null);
- SysTryReturnResult(NID_SYS, errorCode == ALARMMGR_RESULT_SUCCESS, E_SYSTEM, "It is failed to set cb to alarmmgr. error [%d]", errorCode);
- return E_SUCCESS;
-}
-
_AlarmManager*
_AlarmManager::GetInstance(void)
{
void
_AlarmManager::InitSingleton(void)
{
- result r = E_SUCCESS;
_AlarmManager* pAlarmManager = new (std::nothrow) _AlarmManager();
SysTryReturnVoidResult(NID_SYS, pAlarmManager, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
GetErrorMessage(E_OUT_OF_MEMORY));
- r = pAlarmManager->Construct();
- SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to construct alarm manager.");
+
__pAlarmManager = pAlarmManager;
std::atexit(DestroySingleton);
}
ret = alarmmgr_set_type(pAlarmInfo, ALARM_TYPE_NOLAUNCH);
SysTryCatch(NID_SYS, ret == ALARMMGR_RESULT_SUCCESS, r = E_SYSTEM, r, "It is failed to set repeat mode");
- ret = alarmmgr_add_alarm_with_localtime(pAlarmInfo, null, &reservedAlarmId);
+ ret = alarmmgr_add_alarm_appsvc_with_localtime(pAlarmInfo,(void *)pBundle, &reservedAlarmId);
SysTryCatch(NID_SYS, ret == ALARMMGR_RESULT_SUCCESS, r = E_SYSTEM, r, "Alarm creation failed!!! Alrmgr error code is %d", ret);
CATCH: