fix appcontrol result behavior from service callee
[platform/framework/native/appfw.git] / src / app / FApp_AppImpl.cpp
index 5813241..8dd78e2 100644 (file)
@@ -140,7 +140,6 @@ _AppImpl::Construct(const IList* pArgs)
        return E_SUCCESS;
 }
 
-
 result
 _AppImpl::Execute(_IAppImpl* pIAppImpl)
 {
@@ -195,9 +194,7 @@ _AppImpl::Execute(_IAppImpl* pIAppImpl)
        }
 
        // clear outstanding ongoing notification
-       const AppId& appId = _AppInfo::GetApplicationId();
-       std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
-       notification_delete_all_by_type(pAppId.get(), NOTIFICATION_TYPE_ONGOING);
+       notification_delete_all_by_type(appinfo_get_appid(), NOTIFICATION_TYPE_ONGOING);
 
        return r;
 }
@@ -239,7 +236,7 @@ _AppImpl::OnCreate(void* user_data)
 
        if (pAppManager != null)
        {
-               result r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), static_cast<_AppType>(_AppInfo::GetAppType()), _AppInfo::GetProcessId());
+               result r = pAppManager->RegisterApplication(_AppInfo::GetApplicationId(), static_cast<_AppType>(_AppInfo::GetAppType()), _AppInfo::GetProcessId());
                SysTryLog(NID_APP, !IsFailed(r), "[%s] Application registration failed.", GetErrorMessage(r));
        }
        SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:done]", _AppInfo::GetAppExecutableName().GetPointer());
@@ -303,7 +300,7 @@ _AppImpl::OnService(service_s* service, void* user_data)
                service_get_window(service, &winId);
                if (winId > 0)
                {
-                       _AppInfo::GetAppInfo()->SetParentWindowHandle(winId);
+                       _AppInfo::SetParentWindowHandle(winId);
                        SysLog(NID_APP, "Saving window handle 0x%x.", winId);
                }
                // call for callbacks
@@ -688,7 +685,7 @@ _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
                return;
        }
 
-       const String& appId = _AppInfo::GetApplicationId();
+       const char* pAppId = appinfo_get_appid();
 
        const char* p = appsvc_get_operation(arg.GetBundle());
        String operationId = (p) ? String(p) : TIZEN_OPERATION_MAIN;
@@ -697,7 +694,7 @@ _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
                operationId = TIZEN_OPERATION_MAIN;
        }
 
-       SysLog(NID_APP, "AppControl (%ls, %ls).", appId.GetPointer(), operationId.GetPointer());
+       SysLog(NID_APP, "AppControl (%s, %ls).", pAppId, operationId.GetPointer());
 
        String uri;
        String mime;
@@ -728,7 +725,7 @@ _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
 
        pAppControlProviderEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
 
-       SysLog(NID_APP, "AppControl (%ls, %ls) invocation finished.", appId.GetPointer(), operationId.GetPointer());
+       SysLog(NID_APP, "AppControl (%s, %ls) invocation finished.", pAppId, operationId.GetPointer());
 }
 
 
@@ -1191,18 +1188,6 @@ _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
        return;
 
 CATCH:
-       if (r == E_SYSTEM)
-       {
-               pErrorMsg = new (std::nothrow) String("[E_SYSTEM] A system error has occurred.");
-       }
-       else if (r == E_OUT_OF_MEMORY)
-       {
-               pErrorMsg = new (std::nothrow) String("[E_OUT_OF_MEMORY] The memory was insufficient.");
-       }
-       SysTryReturnVoidResult(NID_APP, pErrorMsg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient.");
-
-       res = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, *pErrorMsg);
-
        if (pColumnList)
        {
                pColumnList->RemoveAll(true);
@@ -1221,6 +1206,18 @@ CATCH:
                delete pUpdateMap;
        }
 
+       if (r == E_SYSTEM)
+       {
+               pErrorMsg = new (std::nothrow) String("[E_SYSTEM] A system error has occurred.");
+       }
+       else if (r == E_OUT_OF_MEMORY)
+       {
+               pErrorMsg = new (std::nothrow) String("[E_OUT_OF_MEMORY] The memory was insufficient.");
+       }
+       SysTryReturnVoidResult(NID_APP, pErrorMsg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient.");
+
+       res = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, *pErrorMsg);
+
        delete pErrorMsg;
 
        return;
@@ -1389,21 +1386,35 @@ _AppImpl::IsTerminationRequested(void)
        return __isTerminationRequested;
 }
 
+typedef void (*cbForVconf)(keynode_t* node, void *pData);
+
 void
-_AppImpl::OnPowerOffNotiReceived(void* user_data)
+_AppImpl::OnPowerOffNotiReceived(void* node, void* user_data)
 {
-       SysLog(NID_APP, "Application is being terminated by power off.");
-
-       _AppImpl* pAppImpl = _AppImpl::GetInstance();
-       if (pAppImpl != null)
+       int value = -1;
+       if (!vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &value))
        {
-               pAppImpl->__forcedTermination = true;
+               if (value == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || value == VCONFKEY_SYSMAN_POWER_OFF_RESTART)
+               {
+                       SysLog(NID_APP, "Application is being terminated by power off.");
+
+                       if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (cbForVconf)_AppImpl::OnPowerOffNotiReceived))
+                       {
+                               SysLog(NID_APP, "Fail to ignore vconf for key(%s)", VCONFKEY_SYSMAN_POWER_OFF_STATUS);
+                       }
+
+                       _AppImpl* pAppImpl = _AppImpl::GetInstance();
+                       if (pAppImpl != null)
+                       {
+                               pAppImpl->__forcedTermination = true;
+                       }
+
+                       app_efl_exit();
+               }
        }
-       
-       app_efl_exit();
 }
 
-bool 
+bool
 _AppImpl::IsForcedTermination(void)
 {
        return __forcedTermination;