Revert "Fix duplicated alarms."
authorhansang lee <hs321.lee@samsung.com>
Sat, 19 Oct 2013 09:13:19 +0000 (09:13 +0000)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Sat, 19 Oct 2013 09:13:19 +0000 (09:13 +0000)
This reverts commit c56a863ca20b2a578c5770ce83314e62f8ead995.

Change-Id: I2e91bccad6e3a92204b7c1fe8f8f6299ad0eccda

src/app/FApp_AppImpl.cpp
src/system/FSys_AlarmManager.cpp
src/system/inc/FSys_AlarmManager.h

index e831e70..b1b52fb 100644 (file)
@@ -351,6 +351,29 @@ _AppImpl::OnService(service_s* service, void* user_data)
 
                // 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);
index d15ba62..7ddeb62 100644 (file)
@@ -86,29 +86,6 @@ _AlarmManager::~_AlarmManager()
        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)
 {
@@ -123,12 +100,10 @@ _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);
 }
@@ -188,7 +163,7 @@ _AlarmManager::ReserveAlarm(Tizen::Base::String appId, Tizen::Base::DateTime sta
        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:
index 6b953a6..9fea083 100644 (file)
@@ -45,7 +45,6 @@ public:
        static _AlarmManager* GetInstance(void);
 
 private:
-       result Construct(void);
        int ReserveAlarm(Tizen::Base::String appId, Tizen::Base::DateTime startTime, int period);
        result AddAlarmList(int alarmId, int period, Tizen::Base::String appId, Tizen::Base::DateTime* endTime);
        result RemoveAlarmList(int alarmId);