From 65143e48d23f3098ad3e2bf4b74fca89633cb7ce Mon Sep 17 00:00:00 2001 From: Hyunbin Lee Date: Mon, 8 Apr 2013 16:48:32 +0900 Subject: [PATCH] Refactor DataControl request list. Change-Id: I054d0ea3c4ea873f967767c83a8ee00b5b1366f2 Signed-off-by: Hyunbin Lee --- src/app/CMakeLists.txt | 5 +- src/app/FApp_AppArg.cpp | 28 ++++++++++- src/app/FApp_DataControlManager.cpp | 64 +++++++++++++++++++++++++ src/app/FApp_DataControlManager.h | 55 +++++++++++++++++++++ src/app/FApp_DataControlProviderManagerImpl.cpp | 25 ++++++---- src/app/FApp_MapDataControlImpl.cpp | 58 +++++++++++----------- src/app/FApp_SqlDataControlImpl.cpp | 59 ++++++++++++----------- src/app/inc/FApp_AppArg.h | 10 +++- 8 files changed, 236 insertions(+), 68 deletions(-) create mode 100644 src/app/FApp_DataControlManager.cpp create mode 100644 src/app/FApp_DataControlManager.h diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 47d7ecb..c6cfd4a 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -7,8 +7,8 @@ INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR}/src/base/inc ${CMAKE_SOURCE_DIR}/src/io/inc ${CMAKE_SOURCE_DIR}/src/system/inc - ${CMAKE_SOURCE_DIR}/src/security/inc - inc + ${CMAKE_SOURCE_DIR}/src/security/inc + inc ) SET (${this_target}_SOURCE_FILES @@ -59,6 +59,7 @@ SET (${this_target}_SOURCE_FILES FAppAppControlProviderManager.cpp FApp_AppControlProviderManagerImpl.cpp FApp_AppControlManager.cpp + FApp_DataControlManager.cpp FApp_AppMessageImpl.cpp FAppAppSetting.cpp FApp_AppSettingImpl.cpp diff --git a/src/app/FApp_AppArg.cpp b/src/app/FApp_AppArg.cpp index 40567ac..e3fb502 100644 --- a/src/app/FApp_AppArg.cpp +++ b/src/app/FApp_AppArg.cpp @@ -1121,7 +1121,12 @@ _AppArg::UpdateAppId(bundle* b, const AppId& appId) std::unique_ptr pId(_StringConverter::CopyToCharArrayN(appId)); SysTryReturnVoidResult(NID_APP, pId != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Converting %ls failed.", appId.GetPointer()); - bundle_add(b, OSP_K_APPID, pId.get()); + int res = bundle_add(b, OSP_K_APPID, pId.get()); + if (res < 0 && errno == EPERM) // key exists + { + bundle_del(b, OSP_K_APPID); + bundle_add(b, OSP_K_APPID, pId.get()); + } appsvc_set_appid(b, pId.get()); } @@ -1140,9 +1145,28 @@ _AppArg::UpdateRequestId(bundle* pBundle, int reqId) char buffer[32] = {0, }; snprintf(buffer, 32, "%d", reqId); - bundle_add(pBundle, OSP_K_REQUEST_ID, buffer); + int res = bundle_add(pBundle, OSP_K_REQUEST_ID, buffer); + if (res < 0 && errno == EPERM) // key exists + { + bundle_del(pBundle, OSP_K_REQUEST_ID); + bundle_add(pBundle, OSP_K_REQUEST_ID, buffer); + } } +void +_AppArg::UpdateKeyValue(bundle* pBundle, const char* pKey, const String& value) +{ + SysTryReturnVoidResult(NID_APP, pBundle != null, E_INVALID_STATE, "[E_INVALID_STATE] Improper bundle state."); + + char pBuffer[128] = {0, }; + snprintf(pBuffer, 128, "%ls", value.GetPointer()); + int res = bundle_add(pBundle, pKey, pBuffer); + if (res < 0 && errno == EPERM) // key exists + { + bundle_del(pBundle, pKey); + bundle_add(pBundle, pKey, pBuffer); + } +} int _AppArg::GetRequestIdFromBundle(bundle* pBundle) diff --git a/src/app/FApp_DataControlManager.cpp b/src/app/FApp_DataControlManager.cpp new file mode 100644 index 0000000..3a8a6fa --- /dev/null +++ b/src/app/FApp_DataControlManager.cpp @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FApp_DataControlManager.cpp + * @brief This is the implementation for the _DataControlManager class. + */ + +#include + +#include +#include "FApp_DataControlManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace App +{ + +_DataControlManager::_DataControlManager(void) +{ + __pDataControlRequestList.Construct(); +} + +_DataControlManager::~_DataControlManager(void) +{ +} + +_DataControlManager* +_DataControlManager::GetInstance(void) +{ + static _DataControlManager inst; + return &inst; +} + +void +_DataControlManager::AddEvent(int reqId, Object* pObj) +{ + __pDataControlRequestList.Add(new (std::nothrow) Integer(reqId), pObj); +} + +Object* +_DataControlManager::GetEvent(int reqId) +{ + Integer key(reqId); + return __pDataControlRequestList.GetValue(key); +} + +}} // Tizen::App + diff --git a/src/app/FApp_DataControlManager.h b/src/app/FApp_DataControlManager.h new file mode 100644 index 0000000..6dd8349 --- /dev/null +++ b/src/app/FApp_DataControlManager.h @@ -0,0 +1,55 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FApp_DataControlManager.h + * @brief This is the header file for the _DataControlManager class. + */ + +#ifndef _FAPP_INTERNAL_DATA_CONTROL_MANAGER_H_ +#define _FAPP_INTERNAL_DATA_CONTROL_MANAGER_H_ + +#include +#include + +namespace Tizen { namespace App +{ + +class _DataControlManager + : public Tizen::Base::Object +{ +public: + static _DataControlManager* GetInstance(void); + + void AddEvent(int reqId, Tizen::Base::Object* pObj); + + Tizen::Base::Object* GetEvent(int reqId); + +private: + _DataControlManager(void); + + virtual ~_DataControlManager(void); + +private: + Tizen::Base::Collection::HashMap __pDataControlRequestList; + +}; // _DataControlManager + +}} // Tizen::App + +#endif // _FAPP_INTERNAL_DATA_CONTROL_MANAGER_H_ + diff --git a/src/app/FApp_DataControlProviderManagerImpl.cpp b/src/app/FApp_DataControlProviderManagerImpl.cpp index d4ab5a4..738b385 100644 --- a/src/app/FApp_DataControlProviderManagerImpl.cpp +++ b/src/app/FApp_DataControlProviderManagerImpl.cpp @@ -81,11 +81,12 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon { ArrayList* pList = null; String* pAppId = null; - String* pRequestType = null; + String reqType; int type = 0; _DataControlRequestType requestType = _DATACONTROL_REQUEST_TYPE_UNDEFINED; String* pProviderId = null; - String* pReqId = null; + String* pCallerReqId = null; + int callerReqId = -1; ArrayList* pResultArgList = null; String* pResult = null; String* pErrorMessage = null; @@ -97,6 +98,7 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon String* pResultCount = null; String* pResultValue = null; _AppArg resultArg; + String* pDataId = null; result r = E_SUCCESS; _AppControlManager* pAppMgr = _AppControlManager::GetInstance(); @@ -115,9 +117,8 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon pAppId = dynamic_cast< String* >(pList->GetAt(0)); // request key[0] SysTryCatch(NID_APP, pAppId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object"); - pRequestType = dynamic_cast< String* >(pList->GetAt(1)); // request key[1] - SysTryCatch(NID_APP, pRequestType, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object"); - Integer::Parse(*pRequestType, type); + reqType = arg.GetValue(OSP_K_DATACONTROL_REQUEST_TYPE); + Integer::Parse(reqType, type); requestType = static_cast< _DataControlRequestType >(type); if (providerResult == true && apiType != requestType) @@ -135,12 +136,16 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon } } - pReqId = dynamic_cast< String* >(pList->GetAt(2)); // request key[2] - SysTryCatch(NID_APP, pReqId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object"); + pCallerReqId = dynamic_cast< String* >(pList->GetAt(2)); // request key[2] + SysTryCatch(NID_APP, pCallerReqId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object"); + Integer::Parse(*pCallerReqId, callerReqId); pProviderId = dynamic_cast< String* >(pList->GetAt(3)); // request key[3] SysTryCatch(NID_APP, pProviderId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object"); + pDataId = dynamic_cast< String* >(pList->GetAt(4)); // list[0] + SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object"); + // Serializes the result pResultArgList = new (std::nothrow) ArrayList(); SysTryCatch(NID_APP, pResultArgList, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, @@ -183,7 +188,7 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon String tempFilePath(_DATACONTROL_RESULTSET_DIR); tempFilePath.Append(*pAppId); - tempFilePath.Append(*pReqId); + tempFilePath.Append(*pCallerReqId); pTempFilePath = new (std::nothrow) String(tempFilePath); } else @@ -269,6 +274,10 @@ _DataControlProviderManagerImpl::SendDataControlResult(RequestId reqId, _DataCon r = resultArg.ConstructResult(arg, pResultArgList); SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + resultArg.UpdateRequestId(callerReqId); + resultArg.UpdateKeyValue(OSP_K_DATACONTROL_REQUEST_TYPE, reqType); + resultArg.UpdateKeyValue(OSP_K_DATACONTROL_PROVIDER, *pProviderId); + resultArg.UpdateKeyValue(OSP_K_DATACONTROL_DATA, *pDataId); //resultArg.Print(); r = _Aul::SendResult(resultArg.GetBundle(), static_cast< appsvc_result_val >(0)); diff --git a/src/app/FApp_MapDataControlImpl.cpp b/src/app/FApp_MapDataControlImpl.cpp index 6b2e2d6..5d48ef9 100644 --- a/src/app/FApp_MapDataControlImpl.cpp +++ b/src/app/FApp_MapDataControlImpl.cpp @@ -37,6 +37,7 @@ #include "FApp_AppControlManager.h" #include "FApp_MapDataControlImpl.h" #include "FApp_AppArg.h" +#include "FApp_DataControlManager.h" using namespace std; @@ -176,9 +177,11 @@ _MapDataControlImpl::StartMapDataControl(int type, const IList* pDataList, int* if (__pMapDataControlEvent) { // reqId is system-wide id because the bundle is system-wide. - _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, MapDataControlCallback, __pMapDataControlEvent, -1); - req = reqObj.GetRequestNumber(); + _DataControlManager* pDcMgr = _DataControlManager::GetInstance(); + _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, MapDataControlCallback, pDcMgr, -1); + req = reqObj.GetRequestNumber(); + pDcMgr->AddEvent(req, __pMapDataControlEvent); r = pAppManagerImpl->LaunchApp(__appId, pArg, req); SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propgated.", GetErrorMessage(r)); @@ -262,7 +265,7 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* ArrayList* pResultValueList = null; int resultCount = 0; int requestType = 0; - int reqId = 0; + int callerReqId = -1; int providerRes = 0; bool providerResult = true; bundle* origBundle = null; @@ -276,7 +279,10 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* resBundle = pResArg->GetBundle(); if (resBundle) { - _MapDataControlEvent* pMapDataControlEvent = static_cast< _MapDataControlEvent* >(data); + const char* pCallerReqId = appsvc_get_data(resBundle, OSP_K_REQUEST_ID); + callerReqId = atoi(pCallerReqId); + _DataControlManager* pDcMgr = static_cast< _DataControlManager* >(data); + _MapDataControlEvent* pMapDataControlEvent = dynamic_cast< _MapDataControlEvent* >(pDcMgr->GetEvent(callerReqId)); if (pMapDataControlEvent != null && typeid(pMapDataControlEvent) == typeid(_MapDataControlEvent*)) { @@ -300,33 +306,33 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* // request info origBundle = pArg->GetBundle(); - p = appsvc_get_data(origBundle, OSP_K_DATACONTROL_REQUEST_TYPE); + p = appsvc_get_data(resBundle, OSP_K_DATACONTROL_REQUEST_TYPE); SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); pRequestType = new (std::nothrow) String(p); SysTryCatch(NID_APP, pRequestType, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); Integer::Parse(*pRequestType, requestType); - p = appsvc_get_data(origBundle, OSP_K_REQUEST_ID); - SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); - pReqId = new (std::nothrow) String(p); - SysTryCatch(NID_APP, pReqId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, - "[E_OUT_OF_MEMORY] The memory is insufficient."); - Integer::Parse(*pReqId, reqId); - p = appsvc_get_data(origBundle, OSP_K_DATACONTROL_PROVIDER); + p = appsvc_get_data(resBundle, OSP_K_DATACONTROL_PROVIDER); SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); pProviderId = new (std::nothrow) String(p); SysTryCatch(NID_APP, pProviderId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); - pOrigList = _AppArg::GetListN(origBundle, OSP_K_ARG); - SysTryCatch(NID_APP, pOrigList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); - pDataId = dynamic_cast (pOrigList->GetAt(0)); - SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); + p = appsvc_get_data(resBundle, OSP_K_DATACONTROL_DATA); + SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); + pDataId = new (std::nothrow) String(p); + SysTryCatch(NID_APP, pDataId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); +#if 0 SysLog(NID_APP, "result: %ld, requestType: %d, reqId: %d, providerId: %ls, dataId: %ls, errorMsg: %ls ", providerRes, requestType, reqId, pProviderId->GetPointer(), pDataId->GetPointer(), pErrorMsg->GetPointer()); +#else + SysLog(NID_APP, "result: %ld, requestType: %d, reqId: %d, providerId: %ls, dataId: %ls, errorMsg: %ls ", + providerRes, requestType, callerReqId, pProviderId->GetPointer(), pDataId->GetPointer(), pErrorMsg->GetPointer()); +#endif switch (static_cast< _DataControlRequestType >(requestType)) { @@ -366,7 +372,7 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* } } - pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_QUERY, static_cast (reqId), + pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_QUERY, static_cast (callerReqId), *pProviderId, *pDataId, pResultValueList, providerResult, pErrorMsg); SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); pMapDataControlEvent->Fire(*pEventArg); @@ -375,7 +381,7 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* } case _DATACONTROL_REQUEST_TYPE_MAP_INSERT: { - pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_INSERT, static_cast (reqId), + pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_INSERT, static_cast (callerReqId), *pProviderId, *pDataId, null, providerResult, pErrorMsg); SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); pMapDataControlEvent->Fire(*pEventArg); @@ -383,7 +389,7 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* } case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE: { - pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE, static_cast (reqId), + pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_UPDATE, static_cast (callerReqId), *pProviderId, *pDataId, null, providerResult, pErrorMsg); SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); pMapDataControlEvent->Fire(*pEventArg); @@ -391,7 +397,7 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* } case _DATACONTROL_REQUEST_TYPE_MAP_DELETE: { - pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_DELETE, static_cast (reqId), + pEventArg = new (std::nothrow) _MapDataControlEventArg(_DATACONTROL_REQUEST_TYPE_MAP_DELETE, static_cast (callerReqId), *pProviderId, *pDataId, null, providerResult, pErrorMsg); SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); pMapDataControlEvent->Fire(*pEventArg); @@ -404,8 +410,6 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* pResultList->RemoveAll(true); delete pResultList; - pOrigList->RemoveAll(true); - delete pOrigList; delete pRequestType; delete pReqId; @@ -414,8 +418,13 @@ _MapDataControlImpl::MapDataControlCallback(void* data, _AppArg* pArg, _AppArg* } // Remove the request count +#if 0 SysLog(NID_APP, "Remove a launch request: reqId: %d", reqId); _AppControlManager::GetInstance()->RemoveLaunchRequest(reqId); +#else + SysLog(NID_APP, "Remove a launch request: reqId: %d", callerReqId); + _AppControlManager::GetInstance()->RemoveLaunchRequest(callerReqId); +#endif return E_SUCCESS; @@ -426,11 +435,6 @@ CATCH: delete pResultList; } - if (pOrigList) - { - pOrigList->RemoveAll(true); - delete pOrigList; - } delete pRequestType; delete pReqId; diff --git a/src/app/FApp_SqlDataControlImpl.cpp b/src/app/FApp_SqlDataControlImpl.cpp index 9aaa9d9..79d404b 100644 --- a/src/app/FApp_SqlDataControlImpl.cpp +++ b/src/app/FApp_SqlDataControlImpl.cpp @@ -44,6 +44,7 @@ #include "FApp_AppControlManager.h" #include "FApp_SqlDataControlImpl.h" #include "FApp_AppArg.h" +#include "FApp_DataControlManager.h" using namespace std; @@ -181,9 +182,11 @@ _SqlDataControlImpl::StartSqlDataControl(int type, const IList* pDataList, int* if (__pSqlDataControlEvent) { // reqId is system-wide id because the bundle is system-wide. - _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, SqlDataControlCallback, __pSqlDataControlEvent, -1); - req = reqObj.GetRequestNumber(); + _DataControlManager* pDcMgr = _DataControlManager::GetInstance(); + _AppControlManager::_RequestGuard reqObj = _AppControlManager::_RequestGuard(*pAppManagerImpl, pArg, SqlDataControlCallback, pDcMgr, -1); + req = reqObj.GetRequestNumber(); + pDcMgr->AddEvent(req, __pSqlDataControlEvent); r = pAppManagerImpl->LaunchApp(__appId, pArg, req); SysTryCatch(NID_APP, r == E_SUCCESS, reqObj.Invalidate(), r, "[%s] Propagating.", GetErrorMessage(r)); @@ -309,7 +312,7 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg* String* pInsertRowId = null; _DataControlResultSetEnumerator* pResultSetEnum = null; int requestType = 0; - int reqId = 0; + int callerReqId = -1; int providerRes = 0; bool providerResult = true; bundle* origBundle = null; @@ -323,8 +326,10 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg* resBundle = pResArg->GetBundle(); if (resBundle) { - //ISqlDataControlResponseListener* pListener = static_cast< ISqlDataControlResponseListener* >(data); - _SqlDataControlEvent* pSqlDataControlEvent = static_cast< _SqlDataControlEvent* >(data); + const char* pCallerReqId = appsvc_get_data(resBundle, OSP_K_REQUEST_ID); + callerReqId = atoi(pCallerReqId); + _DataControlManager* pDcMgr = static_cast< _DataControlManager* >(data); + _SqlDataControlEvent* pSqlDataControlEvent = dynamic_cast< _SqlDataControlEvent* >(pDcMgr->GetEvent(callerReqId)); if (pSqlDataControlEvent != null && typeid(pSqlDataControlEvent) == typeid(_SqlDataControlEvent*)) { @@ -348,33 +353,33 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg* origBundle = pArg->GetBundle(); // request info - p = appsvc_get_data(origBundle, OSP_K_DATACONTROL_REQUEST_TYPE); + p = appsvc_get_data(resBundle, OSP_K_DATACONTROL_REQUEST_TYPE); SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); pRequestType = new (std::nothrow) String(p); SysTryCatch(NID_APP, pRequestType, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); Integer::Parse(*pRequestType, requestType); - p = appsvc_get_data(origBundle, OSP_K_REQUEST_ID); - SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); - pReqId = new (std::nothrow) String(p); - SysTryCatch(NID_APP, pReqId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, - "[E_OUT_OF_MEMORY] The memory is insufficient."); - Integer::Parse(*pReqId, reqId); - p = appsvc_get_data(origBundle, OSP_K_DATACONTROL_PROVIDER); + p = appsvc_get_data(resBundle, OSP_K_DATACONTROL_PROVIDER); SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); pProviderId = new (std::nothrow) String(p); SysTryCatch(NID_APP, pProviderId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); - pOrigList = _AppArg::GetListN(origBundle, OSP_K_ARG); - SysTryCatch(NID_APP, pOrigList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); - pDataId = dynamic_cast (pOrigList->GetAt(0)); - SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); + p = appsvc_get_data(resBundle, OSP_K_DATACONTROL_DATA); + SysTryCatch(NID_APP, p, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid bundle"); + pDataId = new (std::nothrow) String(p); + SysTryCatch(NID_APP, pDataId, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); +#if 0 SysLog(NID_APP, "providerResult: %ld, requestType: %d, reqId: %d, providerId: %ls, dataId: %ls, errorMsg: %ls ", providerRes, requestType, reqId, pProviderId->GetPointer(), pDataId->GetPointer(), pErrorMsg->GetPointer()); +#else + SysLog(NID_APP, "providerResult: %ld, requestType: %d, reqId: %d, providerId: %ls, dataId: %ls, errorMsg: %ls ", + providerRes, requestType, callerReqId, pProviderId->GetPointer(), pDataId->GetPointer(), pErrorMsg->GetPointer()); +#endif switch (static_cast <_DataControlRequestType>(requestType)) { @@ -401,7 +406,7 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg* } } - pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_QUERY, static_cast (reqId), + pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_QUERY, static_cast (callerReqId), *pProviderId, *pDataId, pResultSetEnum, -1, providerResult, pErrorMsg); SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); pSqlDataControlEvent->Fire(*pEventArg); @@ -425,7 +430,7 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg* LongLong::Parse(*pInsertRowId, insertRowId); } - pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_INSERT, static_cast (reqId), + pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_INSERT, static_cast (callerReqId), *pProviderId, *pDataId, null, insertRowId, providerResult, pErrorMsg); SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); pSqlDataControlEvent->Fire(*pEventArg); @@ -433,7 +438,7 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg* } case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE: { - pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_UPDATE, static_cast (reqId), + pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_UPDATE, static_cast (callerReqId), *pProviderId, *pDataId, null, -1, providerResult, pErrorMsg); SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); pSqlDataControlEvent->Fire(*pEventArg); @@ -441,7 +446,7 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg* } case _DATACONTROL_REQUEST_TYPE_SQL_DELETE: { - pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_DELETE, static_cast (reqId), + pEventArg = new (std::nothrow) _SqlDataControlEventArg(_DATACONTROL_REQUEST_TYPE_SQL_DELETE, static_cast (callerReqId), *pProviderId, *pDataId, null, -1, providerResult, pErrorMsg); SysTryCatch(NID_APP, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); pSqlDataControlEvent->Fire(*pEventArg); @@ -454,8 +459,6 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg* pResultList->RemoveAll(true); delete pResultList; - pOrigList->RemoveAll(true); - delete pOrigList; delete pRequestType; delete pReqId; @@ -464,8 +467,13 @@ _SqlDataControlImpl::SqlDataControlCallback(void* data, _AppArg* pArg, _AppArg* } // Remove the request count +#if 0 SysLog(NID_APP, "Remove a launch request: reqId: %d", reqId); _AppControlManager::GetInstance()->RemoveLaunchRequest(reqId); +#else + SysLog(NID_APP, "Remove a launch request: reqId: %d", callerReqId); + _AppControlManager::GetInstance()->RemoveLaunchRequest(callerReqId); +#endif return E_SUCCESS; @@ -476,11 +484,6 @@ CATCH: delete pResultList; } - if (pOrigList) - { - pOrigList->RemoveAll(true); - delete pOrigList; - } delete pRequestType; delete pReqId; diff --git a/src/app/inc/FApp_AppArg.h b/src/app/inc/FApp_AppArg.h index 8753d82..4e281d0 100644 --- a/src/app/inc/FApp_AppArg.h +++ b/src/app/inc/FApp_AppArg.h @@ -64,7 +64,8 @@ enum _DataControlRequestType #define OSP_K_APPID "__OSP_APPID__" #define OSP_K_REQUEST_ID "__OSP_REQUEST_ID__" #define OSP_K_APPCONTROL_INTERNAL_OPERATION "__OSP_APPCONTROL_INTERNAL_INTERNAL_OPERATION__" -#define OSP_K_DATACONTROL_PROVIDER "__OSP_DATACONTROL_PROVIDER__" +#define OSP_K_DATACONTROL_PROVIDER "__OSP_DATACONTROL_PROVIDER__" +#define OSP_K_DATACONTROL_DATA "__OSP_DATACONTROL_DATA__" #define OSP_K_DATACONTROL_REQUEST_TYPE "__OSP_DATACONTROL_REQUEST_TYPE__" /** @@ -144,6 +145,11 @@ public: UpdateRequestId(__pBundle, reqId); } + void UpdateKeyValue(const char* pKey, const Tizen::Base::String& value) + { + UpdateKeyValue(__pBundle, pKey, value); + } + result UpdateWindowHandle(long handle) { return UpdateWindowHandle(__pBundle, handle); @@ -169,6 +175,8 @@ public: static void UpdateRequestId(bundle* b, int reqId); + static void UpdateKeyValue(bundle* b, const char* pKey, const Tizen::Base::String& value); + static result UpdateWindowHandle(bundle* b, long handle); static Tizen::Base::Collection::ArrayList* GetListN(bundle* b, const char* key); -- 2.7.4