X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fapp%2FFApp_DataControlManager.cpp;h=aef876c005b3077b3febb14076e8366ebf8fe655;hb=52b443e4763ccd450373a25c48d60d910fc07388;hp=efb211cce0a32657507defc5b22d4900e4919cce;hpb=e1dea92e9e1fbfecaae7167149dfb2994965e1ea;p=platform%2Fframework%2Fnative%2Fappfw.git diff --git a/src/app/FApp_DataControlManager.cpp b/src/app/FApp_DataControlManager.cpp index efb211c..aef876c 100644 --- a/src/app/FApp_DataControlManager.cpp +++ b/src/app/FApp_DataControlManager.cpp @@ -20,16 +20,21 @@ */ #include +#include #include #include #include #include +#include #include #include +#include +#include #include "FApp_DataControlManager.h" +using namespace std; using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -40,17 +45,21 @@ _DataControlManager* _DataControlManager::__pDataControlManagerInstance = null; _DataControlManager::_DataControlManager(void) : __pDataControlRequestList(null) + , __pProviderList(null) , __uniqueId(-1) { __pDataControlRequestList = new (std::nothrow) HashMap(SingleObjectDeleter); SysTryReturnVoidResult(NID_APP, __pDataControlRequestList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); - __pDataControlRequestList->Construct(); + + __pProviderList = new (std::nothrow) LinkedList(SingleObjectDeleter); + SysTryReturnVoidResult(NID_APP, __pProviderList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); } _DataControlManager::~_DataControlManager(void) { delete __pDataControlRequestList; + delete __pProviderList; } void @@ -139,5 +148,46 @@ _DataControlManager::GetUniqueId(void) return __uniqueId; } +void +_DataControlManager::Cache(String& appId) +{ + __pProviderList->Add(new (std::nothrow) String(appId)); +} + +bool +_DataControlManager::IsCached(String& appId) +{ + unique_ptr< IEnumerator > pEnum(__pProviderList->GetEnumeratorN()); + while (pEnum->MoveNext() == E_SUCCESS) + { + String* pCachedAppId = dynamic_cast< String* >(pEnum->GetCurrent()); + if (pCachedAppId != null && pCachedAppId->Equals(appId) == true) + { + return true; + } + } + return false; +} + +result +_DataControlManager::AllowAccess(String& appId) +{ + if (IsCached(appId) == false) + { + unique_ptr< char[] > pPkgId(_StringConverter::CopyToCharArrayN(appId)); + SysTryReturnResult(NID_APP, pPkgId != null, E_SYSTEM, "The method cannot proceed due to a severe system error."); + pPkgId.get()[10] = '\0'; + + int ret = security_server_app_give_access(pPkgId.get(), -1); + SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, + "Failed to call security_server_app_give_access(), provider: %s, ret: %d", pPkgId.get(), ret); + + Cache(appId); + } + + SysLog(NID_APP, "[DC_CALLER_SEND] Allow %ls to access", appId.GetPointer()); + return E_SUCCESS; +} + }} // Tizen::App