From: Krzysztof Dynowski Date: Tue, 17 Oct 2017 11:37:38 +0000 (+0000) Subject: Revert "Implement JS to TEEC binding" X-Git-Tag: submit/tizen/20171018.120842~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=658273d768e61bd8a7c5900b6452dc0a13b63644;p=platform%2Fcore%2Fwebapi%2Flibteec.git Revert "Implement JS to TEEC binding" This reverts commit 10145d6457c9860a4afb8608b998fcba1753e195. Change-Id: I44bf692b06fa50ba69f2d5ea600207e5d88867b9 --- diff --git a/packaging/webapi-plugins-teec.spec b/packaging/webapi-plugins-teec.spec index 04ae34b..4a0ea10 100644 --- a/packaging/webapi-plugins-teec.spec +++ b/packaging/webapi-plugins-teec.spec @@ -25,7 +25,7 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: ninja BuildRequires: pkgconfig(webapi-plugins) -BuildRequires: pkgconfig(tef-libteec) +BuildRequires: tef-libteec %description Tizen TEF Framework Client API plugin diff --git a/src/teec/TeecContext.cc b/src/teec/TeecContext.cc deleted file mode 100644 index 3a9e215..0000000 --- a/src/teec/TeecContext.cc +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecContext class methods definition - */ - -#include "TeecContext.h" -#include "TeecTranslations.h" - -#include -#include - - -namespace extension { -namespace libteec { - -namespace { - -// removes all dashes from UUID string to unify it (if there are any) -std::string UnifyUUID(const std::string& uuid) { - std::string result = uuid; - result.erase(std::remove(result.begin(), result.end(), '-'), result.end()); - return result; -} - -// generates new ID for shared memory -std::string GenerateShmemID() { - static uint64_t counter = 0; - return "shmem-" + std::to_string(counter++); -} - -} // namespace - -TeecContext::TeecContext(const std::string& name) { - TEEC_Result ret = TEEC_InitializeContext(name.empty() ? NULL : name.c_str(), &mContext); - if (ret != TEEC_SUCCESS) { - throw common::NotSupportedException("Failed to initialize context: " + - translations::TeecResultToString(ret)); - } -} - -TeecContext::~TeecContext() { - mSessions.clear(); - mSharedMemories.clear(); - TEEC_FinalizeContext(&mContext); -} - -std::string TeecContext::OpenSession(const std::string& uuidstr, uint32_t connectionMethod, - const void* connectionData, TEEC_Operation* operation, - uint32_t* returnOrigin) { - std::string uuid = UnifyUUID(uuidstr); - auto it = mSessions.find(uuid); - if (it == mSessions.end()) { - mSessions.emplace(uuid, std::make_shared(&mContext, uuid, connectionMethod, - connectionData, operation, returnOrigin)); - return uuid; - } else { - throw common::InvalidValuesException("Session for TA " + uuidstr + " already exists"); - } -} - -TeecSessionPtr TeecContext::GetSession(const std::string& id) { - std::string uuid = UnifyUUID(id); - auto it = mSessions.find(uuid); - if (it == mSessions.end()) { - throw common::InvalidValuesException("Session for TA " + id + " does not exist"); - } - - return it->second; -} - -void TeecContext::CloseSession(const std::string& id) { - std::string uuid = UnifyUUID(id); - mSessions.erase(uuid); -} - -std::string TeecContext::CreateSharedMemory(size_t size, uint32_t flags) { - std::string id = GenerateShmemID(); - mSharedMemories.emplace(id, std::make_shared(&mContext, size, flags)); - return id; -} - -std::string TeecContext::CreateSharedMemory(void* buffer, size_t size, uint32_t flags) { - std::string id = GenerateShmemID(); - mSharedMemories.emplace(id, std::make_shared(&mContext, buffer, size, flags)); - return id; -} - -TeecSharedMemoryPtr TeecContext::GetSharedMemory(const std::string& memId) { - auto it = mSharedMemories.find(memId); - if (it == mSharedMemories.end()) { - throw common::InvalidValuesException("Shared memory " + memId + " does not exist"); - } - return it->second; -} - -void TeecContext::ReleaseSharedMemory(const std::string& memId) { - mSharedMemories.erase(memId); -} - -} // namespace libteec -} // namespace extension diff --git a/src/teec/TeecContext.h b/src/teec/TeecContext.h deleted file mode 100644 index 438a26f..0000000 --- a/src/teec/TeecContext.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecContext class definition - */ - -#ifndef LIBTEEC_TEEC_CONTEXT_H_ -#define LIBTEEC_TEEC_CONTEXT_H_ - -#include "TeecSession.h" -#include "TeecSharedMemory.h" - -#include -#include -#include - - -namespace extension { -namespace libteec { - -using TeecSessionMap = std::unordered_map; -using TeecSharedMemoryMap = std::unordered_map; - -class TeecContext final -{ -public: - TeecContext(const std::string& id); - ~TeecContext(); - - // returns session ID used to recognize sessions in GetSession and CloseSession - std::string OpenSession(const std::string& uuidstr, uint32_t connectionMethod, - const void* connectionData, TEEC_Operation* operation, - uint32_t* returnOrigin); - TeecSessionPtr GetSession(const std::string& id); - void CloseSession(const std::string& id); - - // returns memory ID used to recognise the memory further down the road - std::string CreateSharedMemory(size_t size, uint32_t flags); - std::string CreateSharedMemory(void* buffer, size_t size, uint32_t flags); - TeecSharedMemoryPtr GetSharedMemory(const std::string& memId); - void ReleaseSharedMemory(const std::string& memId); - -private: - TEEC_Context mContext; - TeecSessionMap mSessions; - TeecSharedMemoryMap mSharedMemories; -}; - -using TeecContextPtr = std::shared_ptr; - -} // namespace libteec -} // namespace extension - -#endif // LIBTEEC_TEEC_CONTEXT_H_ \ No newline at end of file diff --git a/src/teec/TeecManager.cc b/src/teec/TeecManager.cc deleted file mode 100644 index edf980c..0000000 --- a/src/teec/TeecManager.cc +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecManager singleton class methods definition - */ - -#include "TeecManager.h" - -#include - -namespace extension { -namespace libteec { - -namespace { - -static uint32_t opIDCounter = 0; - -} // namespace - -TeecManager::TeecManager() { -} - -TeecManager::~TeecManager() { -} - -TeecManager& TeecManager::Instance() { - static TeecManager manager; - return manager; -} - -TeecContextPtr TeecManager::GetContext(const std::string& contextName) { - auto it = mContexts.find(contextName); - if (it == mContexts.end()) { - // no context - create new - TeecContextPtr context = std::make_shared(contextName); - it = mContexts.insert(std::make_pair(contextName, context)).first; - } - - return it->second; -} - -uint32_t TeecManager::CreateOperation() { - std::lock_guard lock(mOperationListMutex); - opIDCounter++; - mOperations.emplace(opIDCounter, TEEC_Operation()); - return opIDCounter; -} - -TEEC_Operation TeecManager::GetOperation(uint32_t id) { - std::lock_guard lock(mOperationListMutex); - auto it = mOperations.find(id); - if (it == mOperations.end()) { - throw common::InvalidValuesException("Operation " + std::to_string(id) + " not found"); - } - return it->second; -} - -void TeecManager::RemoveOperation(uint32_t id) { - std::lock_guard lock(mOperationListMutex); - mOperations.erase(id); -} - -} // namespace libteec -} // namespace extension diff --git a/src/teec/TeecManager.h b/src/teec/TeecManager.h deleted file mode 100644 index a4818cf..0000000 --- a/src/teec/TeecManager.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecManager singleton class definition - */ - -#ifndef LIBTEEC_TEEC_MANAGER_H_ -#define LIBTEEC_TEEC_MANAGER_H_ - -#include -#include -#include -#include -#include -#include - -#include "TeecContext.h" - - -namespace extension { -namespace libteec { - -using TeecContextMap = std::unordered_map; -using TeecOperationMap = std::unordered_map; - -class TeecManager final -{ -public: - static TeecManager& Instance(); - - TeecContextPtr GetContext(const std::string& contextName); - - uint32_t CreateOperation(); - TEEC_Operation GetOperation(uint32_t id); - void RemoveOperation(uint32_t id); - -private: - TeecManager(); - ~TeecManager(); - TeecManager(const TeecManager&) = delete; - TeecManager(TeecManager&&) = delete; - TeecManager& operator=(const TeecManager&) = delete; - TeecManager& operator=(TeecManager&&) = delete; - - TeecContextMap mContexts; - TeecOperationMap mOperations; - std::mutex mOperationListMutex; -}; - -} // namespace libteec -} // namespace extension - -#endif // LIBTEEC_TEEC_MANAGER_H_ \ No newline at end of file diff --git a/src/teec/TeecSession.cc b/src/teec/TeecSession.cc deleted file mode 100644 index 678a2dc..0000000 --- a/src/teec/TeecSession.cc +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecSession class methods definition - */ - -#include "TeecSession.h" -#include "TeecTranslations.h" - -#include "common/logger.h" -#include "common/platform_exception.h" - - -namespace extension { -namespace libteec { - -namespace { - -// assumes UUID already was unified by TeecContext -TEEC_UUID StringToUUID(const std::string& uuidstr) { - if (uuidstr.size() != 32) { - throw common::InvalidValuesException("Bad UUID provided: " + uuidstr); - } - - TEEC_UUID uuid; - uuid.timeLow = std::stoul(uuidstr.substr(0, 8), 0, 16); - uuid.timeMid = static_cast(std::stoul(uuidstr.substr(8, 4), 0, 16)); - uuid.timeHiAndVersion = static_cast(std::stoul(uuidstr.substr(12, 4), 0, 16)); - - uint32_t stringPos = 16; - for (uint32_t i = 0; i < 8; ++i) { - uuid.clockSeqAndNode[i] = static_cast(std::stoul(uuidstr.substr(stringPos, 2), 0, 16)); - stringPos += 2; - } - - return uuid; -} - -} // namespace - -TeecSession::TeecSession(TEEC_Context* ctx, const std::string& uuidstr, - uint32_t connectionMethod, const void* connectionData, - TEEC_Operation* operation, uint32_t* returnOrigin) { - TEEC_UUID uuid = StringToUUID(uuidstr); - TEEC_Result result = TEEC_OpenSession(ctx, &mSession, &uuid, connectionMethod, - connectionData, operation, returnOrigin); - if (result != TEEC_SUCCESS) { - throw common::InvalidValuesException("TEEC Session failed to open: " + - translations::TeecResultToString(result)); - } -} - -TeecSession::~TeecSession() { - TEEC_CloseSession(&mSession); -} - -void TeecSession::InvokeCommand(uint32_t cmd, TEEC_Operation* op, uint32_t* returnOrigin) { - TEEC_Result result = TEEC_InvokeCommand(&mSession, cmd, op, returnOrigin); - if (result != TEEC_SUCCESS) { - throw common::InvalidValuesException("Failure while invoking command " + - std::to_string(cmd) + ": " + - translations::TeecResultToString(result)); - } -} - -} // namespace libteec -} // namespace extension diff --git a/src/teec/TeecSession.h b/src/teec/TeecSession.h deleted file mode 100644 index 5480968..0000000 --- a/src/teec/TeecSession.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecSession class definition - */ - -#ifndef LIBTEEC_TEEC_SESSION_H_ -#define LIBTEEC_TEEC_SESSION_H_ - -#include -#include -#include - -namespace extension { -namespace libteec { - -class TeecSession final -{ -public: - TeecSession(TEEC_Context* ctx, const std::string& uuidstr, - uint32_t connectionMethod, const void* connectionData, - TEEC_Operation* operation, uint32_t* returnOrigin); - ~TeecSession(); - - void InvokeCommand(uint32_t cmd, TEEC_Operation* op, uint32_t* returnOrigin); - -private: - TEEC_Session mSession; -}; - -using TeecSessionPtr = std::shared_ptr; - -} // namespace libteec -} // namespace extension - -#endif // LIBTEEC_TEEC_SESSION_H_ \ No newline at end of file diff --git a/src/teec/TeecSharedMemory.cc b/src/teec/TeecSharedMemory.cc deleted file mode 100644 index 438bb79..0000000 --- a/src/teec/TeecSharedMemory.cc +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecSharedMemory class methods definition - */ - -#include "TeecSharedMemory.h" -#include "TeecTranslations.h" - -#include -#include "common/platform_exception.h" - - -namespace extension { -namespace libteec { - -TeecSharedMemory::TeecSharedMemory(TEEC_Context* ctx, size_t size, uint32_t flags) { - mMemory.buffer = nullptr; - mMemory.size = size; - mMemory.flags = flags; - TEEC_Result result = TEEC_AllocateSharedMemory(ctx, &mMemory); - if (result != TEEC_SUCCESS) { - throw common::InvalidValuesException("Failed to allocate shared memory: " + - translations::TeecResultToString(result) + - " (size " + std::to_string(size) + - ", flags: " + std::to_string(flags)); - } -} - -TeecSharedMemory::TeecSharedMemory(TEEC_Context* ctx, void* buffer, size_t size, uint32_t flags) { - mMemory.buffer = buffer; - mMemory.size = size; - mMemory.flags = flags; - TEEC_Result result = TEEC_RegisterSharedMemory(ctx, &mMemory); - if (result != TEEC_SUCCESS) { - throw common::InvalidValuesException("Failed to allocate shared memory: " + - translations::TeecResultToString(result) + - " (size " + std::to_string(size) + - ", flags: " + std::to_string(flags)); - } -} - -TeecSharedMemory::~TeecSharedMemory() { - TEEC_ReleaseSharedMemory(&mMemory); -} - -void TeecSharedMemory::SetData(const DataBuffer& data, size_t offset) { - if (data.size() > (mMemory.size - offset)) { - throw common::TypeMismatchException("Not enough memory to set data: " + - std::to_string(data.size()) + - " requested, available " + - std::to_string(mMemory.size - offset) + - " at offset " + std::to_string(offset)); - } - - char* sharedBuffer = reinterpret_cast(mMemory.buffer); - memcpy(sharedBuffer + offset, data.data(), data.size()); -} - -void TeecSharedMemory::GetData(DataBuffer& data, size_t offset) const { - if (data.size() > (mMemory.size - offset)) { - throw common::TypeMismatchException("Not enough memory to get data: " + - std::to_string(data.size()) + - " requested, available " + - std::to_string(mMemory.size - offset) + - " at offset " + std::to_string(offset)); - } - - char* sharedBuffer = reinterpret_cast(mMemory.buffer); - memcpy(data.data(), sharedBuffer + offset, data.size()); -} - -TEEC_SharedMemory* TeecSharedMemory::GetMemoryPointer() { - return &mMemory; -} - -} // namespace libteec -} // namespace extension diff --git a/src/teec/TeecSharedMemory.h b/src/teec/TeecSharedMemory.h deleted file mode 100644 index 8625cce..0000000 --- a/src/teec/TeecSharedMemory.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecSharedMemory class definition - */ - -#ifndef LIBTEEC_TEEC_SHARED_MEMORY_H_ -#define LIBTEEC_TEEC_SHARED_MEMORY_H_ - -#include -#include -#include - -namespace extension { -namespace libteec { - -using DataBuffer = std::vector; - -class TeecSharedMemory final -{ -public: - TeecSharedMemory(TEEC_Context* ctx, size_t size, uint32_t flags); - TeecSharedMemory(TEEC_Context* ctx, void* buffer, size_t size, uint32_t flags); - ~TeecSharedMemory(); - - void SetData(const DataBuffer& data, size_t offset); - void GetData(DataBuffer& data, size_t offset) const; - - TEEC_SharedMemory* GetMemoryPointer(); -private: - TEEC_SharedMemory mMemory; -}; - -using TeecSharedMemoryPtr = std::shared_ptr; - -} // namespace libteec -} // namespace extension - -#endif // LIBTEEC_TEEC_SHARED_MEMORY_H_ \ No newline at end of file diff --git a/src/teec/TeecTempMemoryAllocator.cc b/src/teec/TeecTempMemoryAllocator.cc deleted file mode 100644 index f0c3af0..0000000 --- a/src/teec/TeecTempMemoryAllocator.cc +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecTempMemoryAllocator class definition - */ - -#include "TeecTempMemoryAllocator.h" - - -namespace extension { -namespace libteec { - -TeecTempMemoryAllocator::TeecTempMemoryAllocator() { -} - -TeecTempMemoryAllocator::~TeecTempMemoryAllocator() { -} - -void* TeecTempMemoryAllocator::AllocateTempMemory(const picojson::array& array) { - mMemories.emplace_back(array.size()); - - for (size_t i = 0; i < array.size(); ++i) - mMemories.back()[i] = static_cast(array[i].get()); - - return mMemories.back().data(); -} - -} // namespace libteec -} // namespace extension diff --git a/src/teec/TeecTempMemoryAllocator.h b/src/teec/TeecTempMemoryAllocator.h deleted file mode 100644 index 7c70015..0000000 --- a/src/teec/TeecTempMemoryAllocator.h +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * @author Lukasz Kostyra (l.kostyra@samsung.com) - * @brief TeecTempMemoryAllocator class definition - */ - -#ifndef LIBTEEC_TEEC_TEMP_MEMORY_ALLOCATOR_H_ -#define LIBTEEC_TEEC_TEMP_MEMORY_ALLOCATOR_H_ - -#include -#include -#include - - -namespace extension { -namespace libteec { - -using TempMemoryBuffer = std::vector; -using TempMemoryList = std::list; - -// An object used during OpenSession and InvokeCommand calls -// It's purpose is to temporarily allocate buffers on C++ side -// and keep them in memory until above calls end -class TeecTempMemoryAllocator final -{ -public: - TeecTempMemoryAllocator(); - ~TeecTempMemoryAllocator(); - - // returns pointer for temp memory - void* AllocateTempMemory(const picojson::array& array); - -private: - TempMemoryList mMemories; -}; - -} // namespace libteec -} // namespace extension - -#endif // LIBTEEC_TEEC_TEMP_MEMORY_ALLOCATOR_H_ \ No newline at end of file diff --git a/src/teec/TeecTranslations.cc b/src/teec/TeecTranslations.cc deleted file mode 100644 index f381622..0000000 --- a/src/teec/TeecTranslations.cc +++ /dev/null @@ -1,366 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ - -#include "TeecTranslations.h" -#include "TeecManager.h" -#include "TeecContext.h" -#include "TeecSharedMemory.h" -#include - -#define CASE_RESULT_TO_STRING(x) case x: return #x - -namespace extension { -namespace libteec { -namespace translations { - -namespace { - -// JSON TEEC_Parameter parsing tokens -const std::string PARAM_TYPE_KEY = "type"; -const std::string PARAM_TYPE_NONE = "NONE"; -const std::string PARAM_TYPE_VALUE = "VALUE"; -const std::string PARAM_TYPE_MEMREF = "MEMREF"; -const std::string PARAM_TYPE_TMPREF = "TMPREF"; -const std::string PARAM_FLAG_KEY = "flag"; -const std::string PARAM_FLAG_NONE = "NONE"; -const std::string PARAM_FLAG_INPUT = "INPUT"; -const std::string PARAM_FLAG_OUTPUT = "OUTPUT"; -const std::string PARAM_FLAG_INOUT = "INOUT"; -const std::string PARAM_FLAG_WHOLE = "WHOLE"; -const std::string PARAM_FLAG_PARTIAL_INPUT = "PARTIAL_INPUT"; -const std::string PARAM_FLAG_PARTIAL_OUTPUT = "PARTIAL_OUTPUT"; -const std::string PARAM_FLAG_PARTIAL_INOUT = "PARTIAL_INOUT"; -const std::string PARAM_VALUE_A = "a"; -const std::string PARAM_VALUE_B = "a"; -const std::string PARAM_MEMREF_SIZE = "size"; -const std::string PARAM_MEMREF_OFFSET = "offset"; -const std::string PARAM_MEMREF_SHM = "shm"; -const std::string PARAM_TMPREF_MEM = "mem"; - -} // namespace - -std::string TeecResultToString(TEEC_Result result) { - switch (result) { - CASE_RESULT_TO_STRING(TEEC_SUCCESS); - CASE_RESULT_TO_STRING(TEEC_ERROR_GENERIC); - CASE_RESULT_TO_STRING(TEEC_ERROR_ACCESS_DENIED); - CASE_RESULT_TO_STRING(TEEC_ERROR_CANCEL); - CASE_RESULT_TO_STRING(TEEC_ERROR_ACCESS_CONFLICT); - CASE_RESULT_TO_STRING(TEEC_ERROR_EXCESS_DATA); - CASE_RESULT_TO_STRING(TEEC_ERROR_BAD_FORMAT); - CASE_RESULT_TO_STRING(TEEC_ERROR_BAD_PARAMETERS); - CASE_RESULT_TO_STRING(TEEC_ERROR_BAD_STATE); - CASE_RESULT_TO_STRING(TEEC_ERROR_ITEM_NOT_FOUND); - CASE_RESULT_TO_STRING(TEEC_ERROR_NOT_IMPLEMENTED); - CASE_RESULT_TO_STRING(TEEC_ERROR_NOT_SUPPORTED); - CASE_RESULT_TO_STRING(TEEC_ERROR_NO_DATA); - CASE_RESULT_TO_STRING(TEEC_ERROR_OUT_OF_MEMORY); - CASE_RESULT_TO_STRING(TEEC_ERROR_BUSY); - CASE_RESULT_TO_STRING(TEEC_ERROR_COMMUNICATION); - CASE_RESULT_TO_STRING(TEEC_ERROR_SECURITY); - CASE_RESULT_TO_STRING(TEEC_ERROR_SHORT_BUFFER); - CASE_RESULT_TO_STRING(TEEC_ERROR_EXTERNAL_CANCEL); - CASE_RESULT_TO_STRING(TEEC_ERROR_TARGET_DEAD); - // not throwing here, there are TEE internal error not known from - // TEEC header, moreover this function is usually used in throws anyway - default: return "TEEC_ERROR_UNKNOWN"; - } -} - -uint32_t StringToTeecLoginMethod(const std::string& str) { - if (str == "PUBLIC") return TEEC_LOGIN_PUBLIC; - if (str == "USER") return TEEC_LOGIN_USER; - if (str == "GROUP") return TEEC_LOGIN_GROUP; - if (str == "APPLICATION") return TEEC_LOGIN_APPLICATION; - throw common::InvalidValuesException("Invalid login type: " + str); -} - -uint32_t ParamTypeFromJSON(const picojson::object& obj) { - auto typeVal = obj.find(PARAM_TYPE_KEY); - if (typeVal == obj.end()) { - throw common::InvalidValuesException("Missing parameter type info"); - } - - auto flagVal = obj.find(PARAM_FLAG_KEY); - if (flagVal == obj.end()) { - throw common::InvalidValuesException("Flag parameter not added to operation"); - } - - if (typeVal->second.get() == PARAM_TYPE_VALUE) { - if (flagVal->second.get() == PARAM_FLAG_INPUT) { - return TEEC_VALUE_INPUT; - } else if (flagVal->second.get() == PARAM_FLAG_OUTPUT) { - return TEEC_VALUE_OUTPUT; - } else if (flagVal->second.get() == PARAM_FLAG_INOUT) { - return TEEC_VALUE_INOUT; - } else { - throw common::InvalidValuesException("Invalid parameter flag info: " - + flagVal->second.get()); - } - } else if (typeVal->second.get() == PARAM_TYPE_MEMREF) { - if (flagVal->second.get() == PARAM_FLAG_WHOLE) { - return TEEC_MEMREF_WHOLE; - } else if (flagVal->second.get() == PARAM_FLAG_PARTIAL_INPUT) { - return TEEC_MEMREF_PARTIAL_INPUT; - } else if (flagVal->second.get() == PARAM_FLAG_PARTIAL_OUTPUT) { - return TEEC_MEMREF_PARTIAL_OUTPUT; - } else if (flagVal->second.get() == PARAM_FLAG_PARTIAL_INOUT) { - return TEEC_MEMREF_PARTIAL_INOUT; - } else { - throw common::InvalidValuesException("Invalid parameter flag info: " - + flagVal->second.get()); - } - } else if (typeVal->second.get() == PARAM_TYPE_TMPREF) { - if (flagVal->second.get() == PARAM_FLAG_INPUT) { - return TEEC_MEMREF_TEMP_INPUT; - } else if (flagVal->second.get() == PARAM_FLAG_OUTPUT) { - return TEEC_MEMREF_TEMP_OUTPUT; - } else if (flagVal->second.get() == PARAM_FLAG_INOUT) { - return TEEC_MEMREF_TEMP_INOUT; - } else { - throw common::InvalidValuesException("Invalid parameter flag info: " - + flagVal->second.get()); - } - } - - throw common::InvalidValuesException("Invalid parameter type info: " - + typeVal->second.get()); -} - -TEEC_SharedMemory* SharedMemoryFromJSON(const picojson::object& object) { - auto cID = object.find("contextId"); - auto mID = object.find("memId"); - - if (cID == object.end() || mID == object.end()) { - throw common::InvalidValuesException("Invalid shared memory object provided as param"); - } - - const std::string& contextId = cID->second.get(); - const std::string& memId = mID->second.get(); - TeecContextPtr context = TeecManager::Instance().GetContext(contextId); - TeecSharedMemoryPtr mem = context->GetSharedMemory(memId); - return mem->GetMemoryPointer(); -} - -TEEC_Operation OperationFromJSON(const picojson::value& value, TeecTempMemoryAllocator& allocator) { - TEEC_Operation result; - result.started = 0; - result.paramTypes = 0; - - if (!value.is()) { - return result; - } - - std::vector paramTypes(4); - for (auto& p: paramTypes) { - p = TEEC_NONE; - } - - const picojson::array& array = value.get(); - if (array.size() > 4) { - throw common::InvalidValuesException("Too many operation parameters"); - } - - for (uint32_t i = 0; i < array.size(); ++i) { - const picojson::object& paramObject = array[i].get(); - - auto type = paramObject.find(PARAM_TYPE_KEY); - if (type != paramObject.end()) { - paramTypes[i] = ParamTypeFromJSON(paramObject); - const std::string& paramType = type->second.get(); - if (paramType == PARAM_TYPE_VALUE) { - auto valA = paramObject.find(PARAM_VALUE_A); - auto valB = paramObject.find(PARAM_VALUE_B); - if (valA != paramObject.end() && valB != paramObject.end()) { - result.params[i].value.a = static_cast(valA->second.get()); - result.params[i].value.b = static_cast(valB->second.get()); - } - } else if (paramType == PARAM_TYPE_MEMREF) { - auto size = paramObject.find(PARAM_MEMREF_SIZE); - auto offset = paramObject.find(PARAM_MEMREF_OFFSET); - auto shm = paramObject.find(PARAM_MEMREF_SHM); - if (size != paramObject.end() && - offset != paramObject.end() && - shm != paramObject.end()) { - result.params[i].memref.size = static_cast(size->second.get()); - result.params[i].memref.offset = static_cast(offset->second.get()); - result.params[i].memref.parent = SharedMemoryFromJSON(shm->second.get()); - } - } else if (paramType == PARAM_TYPE_TMPREF) { - auto mem = paramObject.find(PARAM_TMPREF_MEM); - if (mem != paramObject.end()) { - const picojson::array& tmpMem = mem->second.get(); - result.params[i].tmpref.size = tmpMem.size(); - result.params[i].tmpref.buffer = allocator.AllocateTempMemory(tmpMem); - } - } else { - throw common::InvalidValuesException("Invalid parameter type provided: " - + type->second.get()); - } - } - } - - result.paramTypes = TEEC_PARAM_TYPES(paramTypes[0], paramTypes[1], paramTypes[2], paramTypes[3]); - return result; -} - -uint32_t SharedMemoryFlagsFromJSON(const picojson::value& value) { - if (!value.is()) { - throw common::InvalidValuesException("Attempted to acquire shared memory flag from non-string object"); - } - - const std::string& flagStr = value.get(); - if (flagStr == PARAM_FLAG_INPUT) { - return TEEC_MEM_INPUT; - } else if (flagStr == PARAM_FLAG_OUTPUT) { - return TEEC_MEM_OUTPUT; - } else if (flagStr == PARAM_FLAG_INOUT) { - return TEEC_MEM_INPUT | TEEC_MEM_OUTPUT; - } - - throw common::InvalidValuesException("Invalid flag provided: " + flagStr); -} - -DataBuffer DataBufferFromJSON(const picojson::value& value) { - if (!value.is()) { - throw common::InvalidValuesException("Attempted to acquire data array from non-array object"); - } - - const picojson::array& array = value.get(); - DataBuffer buffer(array.size()); - - for (size_t i = 0; i < array.size(); ++i) { - buffer[i] = static_cast(array[i].get()); - } - - return buffer; -} - -std::string JSONFromParamType(uint32_t paramType) { - switch (paramType) { - case TEEC_NONE: - return PARAM_TYPE_NONE; - case TEEC_VALUE_INPUT: - case TEEC_VALUE_OUTPUT: - case TEEC_VALUE_INOUT: - return PARAM_TYPE_VALUE; - case TEEC_MEMREF_TEMP_INPUT: - case TEEC_MEMREF_TEMP_OUTPUT: - case TEEC_MEMREF_TEMP_INOUT: - return PARAM_TYPE_TMPREF; - case TEEC_MEMREF_WHOLE: - case TEEC_MEMREF_PARTIAL_INPUT: - case TEEC_MEMREF_PARTIAL_OUTPUT: - case TEEC_MEMREF_PARTIAL_INOUT: - return PARAM_TYPE_MEMREF; - default: - throw common::InvalidValuesException("Unknown TEEC parameter type: " + std::to_string(paramType)); - }; -} - -std::string JSONFromParamFlag(uint32_t paramType) { - switch (paramType) { - case TEEC_NONE: - return PARAM_FLAG_NONE; - case TEEC_VALUE_INPUT: - case TEEC_MEMREF_TEMP_INPUT: - return PARAM_FLAG_INPUT; - case TEEC_VALUE_OUTPUT: - case TEEC_MEMREF_TEMP_OUTPUT: - return PARAM_FLAG_OUTPUT; - case TEEC_VALUE_INOUT: - case TEEC_MEMREF_TEMP_INOUT: - return PARAM_FLAG_INOUT; - case TEEC_MEMREF_WHOLE: - return PARAM_FLAG_WHOLE; - case TEEC_MEMREF_PARTIAL_INPUT: - return PARAM_FLAG_PARTIAL_INPUT; - case TEEC_MEMREF_PARTIAL_OUTPUT: - return PARAM_FLAG_PARTIAL_OUTPUT; - case TEEC_MEMREF_PARTIAL_INOUT: - return PARAM_FLAG_PARTIAL_INOUT; - default: - throw common::InvalidValuesException("Unknown TEEC parameter type: " + std::to_string(paramType)); - }; -} - -picojson::value UpdateJSONParams(const picojson::value& json, TEEC_Operation op) { - const picojson::array& inParamArray = json.get(); - picojson::array outParamArray; - - uint32_t paramTypes[4] = { - TEEC_PARAM_TYPE_GET(op.paramTypes, 0), - TEEC_PARAM_TYPE_GET(op.paramTypes, 1), - TEEC_PARAM_TYPE_GET(op.paramTypes, 2), - TEEC_PARAM_TYPE_GET(op.paramTypes, 3), - }; - - for (uint32_t i = 0; i < 4; ++i) { - picojson::object param; - - std::string paramType = JSONFromParamType(paramTypes[i]); - param.insert(std::make_pair(PARAM_TYPE_KEY, picojson::value(paramType))); - param.insert(std::make_pair(PARAM_FLAG_KEY, picojson::value(JSONFromParamFlag(paramTypes[i])))); - - if (paramType == PARAM_TYPE_VALUE) { - // value type can be completely overwritten - param.insert(std::make_pair(PARAM_VALUE_A, - picojson::value(static_cast(op.params[i].value.a)))); - param.insert(std::make_pair(PARAM_VALUE_B, - picojson::value(static_cast(op.params[i].value.b)))); - } else if (paramType == PARAM_TYPE_MEMREF) { - const picojson::object& memref = inParamArray[i].get(); - auto shm = memref.find("shm"); - if (shm == memref.end()) { - throw common::InvalidValuesException("Invalid shm object"); - } - - // memref type copies shm from source, rest parameters from TA - param.insert(std::make_pair(PARAM_MEMREF_SIZE, - picojson::value(static_cast(op.params[i].memref.size)))); - param.insert(std::make_pair(PARAM_MEMREF_OFFSET, - picojson::value(static_cast(op.params[i].memref.offset)))); - param.insert(std::make_pair(PARAM_MEMREF_SHM, shm->second)); - } else if (paramType == PARAM_TYPE_TMPREF) { - picojson::array buf(op.params[i].tmpref.size); - uint8_t* opBuf = reinterpret_cast(op.params[i].tmpref.buffer); - for (size_t i = 0; i < buf.size(); ++i) - buf[i] = picojson::value(static_cast(opBuf[i])); - - param.insert(std::make_pair(PARAM_TMPREF_MEM, picojson::value(buf))); - } else if (paramType != PARAM_TYPE_NONE) { - throw common::InvalidValuesException("Invalid parameter type read from operation: " + paramType); - } - - outParamArray.push_back(picojson::value(param)); - } - - return picojson::value(outParamArray); -} - -picojson::value JSONFromDataBuffer(const DataBuffer& buffer) { - picojson::array result(buffer.size()); - - for (uint32_t i = 0; i < buffer.size(); ++i) { - result[i] = picojson::value(static_cast(buffer[i])); - } - - return picojson::value(result); -} - -} // namespace translations -} // namespace libteec -} // namespace extension diff --git a/src/teec/TeecTranslations.h b/src/teec/TeecTranslations.h deleted file mode 100644 index da126b8..0000000 --- a/src/teec/TeecTranslations.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ - -#ifndef LIBTEEC_TEEC_TRANSLATIONS_H_ -#define LIBTEEC_TEEC_TRANSLATIONS_H_ - -#include "TeecSharedMemory.h" - -#include "TeecTempMemoryAllocator.h" - -#include -#include - -#include -#include - - -namespace extension { -namespace libteec { -namespace translations { - -std::string TeecResultToString(TEEC_Result result); -uint32_t StringToTeecLoginMethod(const std::string& str); -TEEC_Operation OperationFromJSON(const picojson::value& value, TeecTempMemoryAllocator& allocator); -DataBuffer DataBufferFromJSON(const picojson::value& value); -uint32_t SharedMemoryFlagsFromJSON(const picojson::value& value); -picojson::value UpdateJSONParams(const picojson::value& json, TEEC_Operation op); -picojson::value JSONFromDataBuffer(const DataBuffer& buffer); - -} // namespace translations -} // namespace libteec -} // namespace extension - -#endif // LIBTEEC_TEEC_TRANSLATIONS_H_ diff --git a/src/teec/libteec_api.js b/src/teec/libteec_api.js index 346b4f9..68811dd 100644 --- a/src/teec/libteec_api.js +++ b/src/teec/libteec_api.js @@ -60,13 +60,17 @@ ListenerManager.prototype.removeListener = function(watchId, nativeCall) { } if (this.nativeSet && type_.isEmptyObject(this.listeners)) { - this.native.callSync(nativeCall); - this.native.removeListener(this.listenerName); - this.nativeSet = false; + this.native.callSync(nativeCall); + this.native.removeListener(this.listenerName); + this.nativeSet = false; } }; +function SetReadOnlyProperty(obj, n, v) { + Object.defineProperty(obj, n, {value: v, writable: false}); +} + var TeecLoginMethod = { PUBLIC: 'PUBLIC', USER: 'USER', @@ -95,15 +99,14 @@ var TeecSharedMemoryFlags = { INOUT: 'INOUT' }; -function TeecParameter() { -} - - function LibTeecManager() { + // constructor of LibTeecManager + } -LibTeecManager.prototype.getContext = function() { + +LibTeecManager.prototype.getContext = function(name) { var args = validator_.validateArgs(arguments, [ {name: 'name', type: types_.STRING, optional: true, nullable: true} ]); @@ -112,137 +115,58 @@ LibTeecManager.prototype.getContext = function() { name: args.name }; + var result = native_.callSync('LibTeecManager_getContext', data); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } - return new TeecContext(native_.getResultObject(result)); -}; - - - -function TeecSession(contextId, sessionId) { - this.contextId = contextId; - this.sessionId = sessionId; -} - -TeecSession.prototype.close = function() { - var data = { - contextId: this.contextId, - sessionId: this.sessionId - }; - var result = native_.callSync('TeecSession_close', data); - - if (native_.isFailure(result)) { - throw native_.getErrorObject(result); - } }; -TeecSession.prototype.invokeCommand = - function(cmd, params, successCallback, errorCallback) { - var args = validator_.validateArgs(arguments, [ - {name: 'cmd', type: types_.LONG}, - {name: 'params', type: types_.ARRAY, values: TeecParameter, - nullable: true}, - {name: 'successCallback', type: types_.FUNCTION}, - {name: 'errorCallback', type: types_.FUNCTION, optional: true, - nullable: true} - ]); - var data = { - contextId: this.contextId, - sessionId: this.sessionId, - cmd: args.cmd, - params: args.params, - successCallback: args.successCallback, - errorCallback: args.errorCallback - }; - var callback = function(result) { - if (native_.isFailure(result)) { - native_.callIfPossible(args.errorCallback, - native_.getErrorObject(result)); - return; - } - - var retArgs = native_.getResultObject(result); - - // update parameters after call - // to avoid losing TeecSharedMemory's functions, we copy MEMREF - // attributes via a function, instead of a typical substitution - for (var i = 0; i < params.length; ++i) { - if (params[i].type === 'VALUE') { - params[i] = retArgs.params[i]; - } else if (params[i].type === 'MEMREF') { - params[i].copyParams(retArgs.params[i]); - } else if (params[i].type === 'TMPREF') { - params[i] = retArgs.params[i]; - } - } - - native_.callIfPossible(args.successCallback, retArgs.cmd, params); - }; - - var result = native_.call('TeecSession_invokeCommand', data, callback); - - if (native_.isFailure(result)) { - throw native_.getErrorObject(result); - } - - return native_.getResultObject(result); -}; - - - -function TeecContext(id) { +function TeecContext() { // constructor of TeecContext - this.contextId = id; + } -TeecContext.prototype.openSession = - function(taUUID, loginMethod, connectionData, params, successCallback, - errorCallback) { + +TeecContext.prototype.openSession = function(taUUID, loginMethod, connectionData, params, successCallback, errorCallback) { var args = validator_.validateArgs(arguments, [ {name: 'taUUID', type: types_.STRING}, - {name: 'loginMethod', type: types_.ENUM, - values: ['PUBLIC', 'USER', 'GROUP', 'APPLICATION']}, - {name: 'connectionData', type: types_.UNSIGNED_LONG, nullable: true}, - {name: 'params', type: types_.ARRAY, values: TeecParameter, - nullable: true}, + {name: 'loginMethod', type: types_.ENUM, values: ['PUBLIC', 'USER', 'GROUP', 'APPLICATION']}, + {name: 'connectionData', type: types_.BYTE}, + {name: 'params', type: types_.PLATFORM_OBJECT, values: tizen.TeecParameter}, {name: 'successCallback', type: types_.FUNCTION}, - {name: 'errorCallback', type: types_.FUNCTION, optional: true, - nullable: true} + {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true} ]); var data = { - contextId: this.contextId, taUUID: args.taUUID, loginMethod: args.loginMethod, connectionData: args.connectionData, params: args.params }; - var cId = this.contextId; + + + + + var callback = function(result) { if (native_.isFailure(result)) { native_.callIfPossible(args.errorCallback, native_.getErrorObject(result)); return; } - - var session = new TeecSession(cId, native_.getResultObject(result)); - native_.callIfPossible(args.successCallback, session); + native_.callIfPossible(args.successCallback); }; - var result = native_.call('TeecContext_openSession', data, callback); + native_.call('TeecContext_openSession', data, callback); + - if (native_.isFailure(result)) { - throw native_.getErrorObject(result); - } - return native_.getResultObject(result); }; TeecContext.prototype.revokeCommand = function(id) { @@ -254,11 +178,13 @@ TeecContext.prototype.revokeCommand = function(id) { id: args.id }; + var result = native_.callSync('TeecContext_revokeCommand', data); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } + }; TeecContext.prototype.allocateSharedMemory = function(size, flags) { @@ -268,18 +194,18 @@ TeecContext.prototype.allocateSharedMemory = function(size, flags) { ]); var data = { - contextId: this.contextId, size: args.size, flags: args.flags }; + var result = native_.callSync('TeecContext_allocateSharedMemory', data); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } + return new TeecSharedMemory(native_.getResultObject(result)); - return new TeecSharedMemory(this.contextId, native_.getResultObject(result)); }; TeecContext.prototype.registerSharedMemory = function(addr, size, flags) { @@ -295,13 +221,14 @@ TeecContext.prototype.registerSharedMemory = function(addr, size, flags) { flags: args.flags }; + var result = native_.callSync('TeecContext_registerSharedMemory', data); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } + return new TeecSharedMemory(native_.getResultObject(result)); - return new TeecSharedMemory(this.contextId, native_.getResultObject(result)); }; TeecContext.prototype.releaseSharedMemory = function(shm) { @@ -310,133 +237,88 @@ TeecContext.prototype.releaseSharedMemory = function(shm) { ]); var data = { - contextId: this.contextId, - memId: shm.memId, + shm: args.shm }; + var result = native_.callSync('TeecContext_releaseSharedMemory', data); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } + }; -function TeecSharedMemory(contextId, memId) { +function TeecSharedMemory() { // constructor of TeecSharedMemory - this.contextId = contextId; - this.memId = memId; + + SetReadOnlyProperty(this, 'size', null); // read only property } + TeecSharedMemory.prototype.setData = function(data, offset) { var args = validator_.validateArgs(arguments, [ - {name: 'data', type: types_.ARRAY, values: types_.BYTE }, - {name: 'offset', type: types_.LONG_LONG } + {name: 'data', type: types_.BYTE}, + {name: 'offset', type: types_.LONG_LONG} ]); - var packed = { - contextId: this.contextId, - memId: this.memId, + var data = { data: args.data, offset: args.offset }; - var result = native_.callSync('TeecSharedMemory_setData', packed); + + var result = native_.callSync('TeecSharedMemory_setData', data); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } + }; TeecSharedMemory.prototype.getData = function(data, offset) { var args = validator_.validateArgs(arguments, [ - {name: 'data', type: types_.ARRAY, values: types_.BYTE }, + {name: 'data', type: types_.BYTE}, {name: 'offset', type: types_.LONG_LONG} ]); - var packed = { - contextId: this.contextId, - memId: this.memId, + var data = { data: args.data, offset: args.offset }; - var result = native_.callSync('TeecSharedMemory_getData', packed); + + var result = native_.callSync('TeecSharedMemory_getData', data); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } - var out = native_.getResultObject(result); - for (var i = 0; i < data.length; ++i) - data[i] = out[i]; -}; - -TeecSharedMemory.prototype.copyParams = function(src) { - this.contextId = src.contextId; - this.memId = src.memId; }; -function TeecValue(a, b, flag) { - // constructor of TeecValue - validator_.isConstructorCall(this, TeecValue); - var args = validator_.validateArgs(arguments, [ - {name: 'a', type: types_.UNSIGNED_LONG}, - {name: 'b', type: types_.UNSIGNED_LONG}, - {name: 'flag', type: types_.ENUM, values: ['INPUT', 'OUTPUT', 'INOUT']} - ]); - - this.type = "VALUE"; - this.flag = args.flag; - this.a = args.a; - this.b = args.b; -} - -TeecValue.prototype = new TeecParameter(); -TeecValue.prototype.constructor = TeecValue; - -function TeecRegisteredMemory(memory, offset, size, flag) { +function TeecRegisteredMemory(memory, offset, size) { // constructor of TeecRegisteredMemory validator_.isConstructorCall(this, TeecRegisteredMemory); - var args = validator_.validateArgs(arguments, [ - {name: 'memory', type: types_.PLATFORM_OBJECT, values: TeecSharedMemory }, - {name: 'offset', type: types_.UNSIGNED_LONG_LONG }, - {name: 'size', type: types_.UNSIGNED_LONG_LONG }, - {name: 'flag', type: types_.ENUM, values: ['WHOLE', 'PARTIAL_INPUT', 'PARTIAL_OUTPUT', 'PARTIAL_INOUT']} - ]); - this.type = "MEMREF"; - this.flag = args.flag; - this.shm = memory; - this.size = args.size; - this.offset = args.offset; + this.shm = null; + this.offset = offset; + this.size = memory.size; } TeecRegisteredMemory.prototype = new TeecParameter(); TeecRegisteredMemory.prototype.constructor = TeecRegisteredMemory; -TeecRegisteredMemory.prototype.copyParams = function(src) { - this.type = src.type; - this.flag = src.flag; - this.size = src.size; - this.offset = src.offset; - this.shm.copyParams(src.shm); -}; -function TeecTempMemory(mem, flag) { + +function TeecTempMemory(mem) { // constructor of TeecTempMemory validator_.isConstructorCall(this, TeecTempMemory); - var args = validator_.validateArgs(arguments, [ - {name: 'mem', type: types_.ARRAY, values: types_.BYTE }, - {name: 'flag', type: types_.ENUM, values: ['INPUT', 'OUTPUT', 'INOUT']} - ]); - this.type = "TMPREF"; - this.mem = args.mem; - this.flag = args.flag; + this.mem = mem; } TeecTempMemory.prototype = new TeecParameter(); @@ -444,15 +326,23 @@ TeecTempMemory.prototype.constructor = TeecTempMemory; -exports = new LibTeecManager(); -tizen.TeecLoginMethod = TeecLoginMethod; -tizen.TeecValueType = TeecValueType; -tizen.TeecTempMemoryType = TeecTempMemoryType; -tizen.TeecRegisteredMemoryType = TeecRegisteredMemoryType; -tizen.TeecSharedMemoryFlags = TeecSharedMemoryFlags; +function TeecValue(a, b) { + // constructor of TeecValue + validator_.isConstructorCall(this, TeecValue); + + this.a = a; + this.b = b; +} + +TeecValue.prototype = new TeecParameter(); +TeecValue.prototype.constructor = TeecValue; + + +exports = new LibTeecManager(); tizen.TeecContext = TeecContext; -tizen.TeecSession = TeecSession; +tizen.TeecSharedMemory = TeecSharedMemory; tizen.TeecRegisteredMemory = TeecRegisteredMemory; tizen.TeecTempMemory = TeecTempMemory; tizen.TeecValue = TeecValue; + diff --git a/src/teec/libteec_instance.cc b/src/teec/libteec_instance.cc index e119ab2..5ac689c 100644 --- a/src/teec/libteec_instance.cc +++ b/src/teec/libteec_instance.cc @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,20 @@ * limitations under the License. */ -#include "libteec_instance.h" -#include "TeecManager.h" -#include "TeecContext.h" -#include "TeecTranslations.h" -#include "TeecTempMemoryAllocator.h" +#include "teec/libteec_instance.h" #include -#include -#include -#include -#include -#include -#include - +#include "common/picojson.h" +#include "common/logger.h" +#include "common/platform_exception.h" namespace extension { namespace libteec { namespace { - -// The privilege required in Libteec API -const std::string kPrivilegeLibteec = "http://tizen.org/privilege/tee.client"; +// The privileges that required in Libteec API +const std::string kPrivilegeLibteec = ""; } // namespace @@ -48,296 +39,198 @@ LibteecInstance::LibteecInstance() { #define REGISTER_SYNC(c,x) \ RegisterSyncHandler(c, std::bind(&LibteecInstance::x, this, _1, _2)); REGISTER_SYNC("LibTeecManager_getContext", LibTeecManagerGetContext); - REGISTER_SYNC("TeecSharedMemory_getData", TeecSharedMemoryGetData); REGISTER_SYNC("TeecSharedMemory_setData", TeecSharedMemorySetData); REGISTER_SYNC("TeecContext_releaseSharedMemory", TeecContextReleaseSharedMemory); + REGISTER_SYNC("TeecContext_openSession", TeecContextOpenSession); REGISTER_SYNC("TeecContext_registerSharedMemory", TeecContextRegisterSharedMemory); REGISTER_SYNC("TeecContext_allocateSharedMemory", TeecContextAllocateSharedMemory); + REGISTER_SYNC("TeecSharedMemory_getData", TeecSharedMemoryGetData); REGISTER_SYNC("TeecContext_revokeCommand", TeecContextRevokeCommand); - REGISTER_SYNC("TeecSession_close", TeecSessionClose); #undef REGISTER_SYNC - - #define REGISTER_ASYNC(c,x) \ - RegisterSyncHandler(c, std::bind(&LibteecInstance::x, this, _1, _2)); - REGISTER_ASYNC("TeecContext_openSession", TeecContextOpenSession); - REGISTER_ASYNC("TeecSession_invokeCommand", TeecSessionInvokeCommand); - #undef REGISTER_ASYNC } LibteecInstance::~LibteecInstance() { } + +enum LibteecCallbacks { + LibTeecManagerGetContextCallback, + TeecSharedMemorySetDataCallback, + TeecContextReleaseSharedMemoryCallback, + TeecContextOpenSessionCallback, + TeecContextRegisterSharedMemoryCallback, + TeecContextAllocateSharedMemoryCallback, + TeecSharedMemoryGetDataCallback, + TeecContextRevokeCommandCallback +}; + +static void ReplyAsync(LibteecInstance* instance, LibteecCallbacks cbfunc, + int callbackId, bool isSuccess, picojson::object& param) { + param["callbackId"] = picojson::value(static_cast(callbackId)); + param["status"] = picojson::value(isSuccess ? "success" : "error"); + + // insert result for async callback to param + switch(cbfunc) { + case LibTeecManagerGetContextCallback: { + // do something... + break; + } + case TeecContextOpenSessionCallback: { + // do something... + break; + } + case TeecContextRevokeCommandCallback: { + // do something... + break; + } + case TeecContextAllocateSharedMemoryCallback: { + // do something... + break; + } + case TeecContextRegisterSharedMemoryCallback: { + // do something... + break; + } + case TeecContextReleaseSharedMemoryCallback: { + // do something... + break; + } + case TeecSharedMemorySetDataCallback: { + // do something... + break; + } + case TeecSharedMemoryGetDataCallback: { + // do something... + break; + } + default: { + LoggerE("Invalid Callback Type"); + return; + } + } + + picojson::value result = picojson::value(param); + + instance->PostMessage(result.serialize().c_str()); +} + #define CHECK_EXIST(args, name, out) \ if (!args.contains(name)) {\ ReportError(TypeMismatchException(name" is required argument"), out);\ return;\ } + void LibteecInstance::LibTeecManagerGetContext(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); - const picojson::value& name = args.get("name"); - std::string contextName; + const std::string& name = args.get("name").get(); - if (name.is()) { - contextName = name.get(); - } + // implement it - try { - TeecContextPtr ctx = TeecManager::Instance().GetContext(contextName); - ReportSuccess(picojson::value(contextName), out); - } catch (const PlatformException& e) { - ReportError(e, out); - } -} + // if success + // ReportSuccess(out); + // if error + // ReportError(out); +} void LibteecInstance::TeecContextOpenSession(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); CHECK_EXIST(args, "callbackId", out) - CHECK_EXIST(args, "contextId", out) - CHECK_EXIST(args, "taUUID", out) - CHECK_EXIST(args, "loginMethod", out) - - double callbackId = args.get("callbackId").get(); - std::string contextId = args.get("contextId").get(); - std::string uuid = args.get("taUUID").get(); - const uint32_t loginMethod = translations::StringToTeecLoginMethod(args.get("loginMethod").get()); - - TeecContextPtr context; - uint32_t connectionData = 0; - uint32_t* connectionDataPtr = nullptr; - uint32_t opId = 0; - - try { - context = TeecManager::Instance().GetContext(contextId); - - if (args.get("connectionData").is()) { - connectionData = static_cast(args.get("connectionData").get()); - connectionDataPtr = &connectionData; - } + CHECK_EXIST(args, "connectionData", out) - opId = TeecManager::Instance().CreateOperation(); - } catch (const PlatformException& e) { - ReportError(e, out); - } + int callbackId = static_cast(args.get("callbackId").get()); + int connectionData = args.get("connectionData").get(); - auto openSession = [=](const std::shared_ptr& response) -> void { - try { - TeecTempMemoryAllocator allocator; - - TEEC_Operation op = TeecManager::Instance().GetOperation(opId); - op.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE); - if (args.get("params").is()) { - op = translations::OperationFromJSON(args.get("params"), allocator); - } - - std::string sid = context->OpenSession(uuid, loginMethod, connectionDataPtr, &op, nullptr); - TeecManager::Instance().RemoveOperation(opId); - ReportSuccess(picojson::value(sid), response->get()); - } catch (const PlatformException& e) { - ReportError(e, response->get()); - } - }; + // implement it - auto openSessionResponse = - [callbackId, this](const std::shared_ptr& response) -> void { - picojson::object& obj = response->get(); - obj.insert(std::make_pair("callbackId", picojson::value(callbackId))); - Instance::PostMessage(this, response->serialize().c_str()); - }; + // call ReplyAsync in later (Asynchronously) - auto data = std::shared_ptr(new picojson::value(picojson::object())); + // if success + // ReportSuccess(out); + // if error + // ReportError(out); +} +void LibteecInstance::TeecContextRevokeCommand(const picojson::value& args, picojson::object& out) { - TaskQueue::GetInstance().Queue(openSession, openSessionResponse, data); - ReportSuccess(picojson::value(static_cast(opId)), out); -} + // implement it -void LibteecInstance::TeecContextRevokeCommand(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); - CHECK_EXIST(args, "id", out); - - try { - uint32_t id = static_cast(args.get("id").get()); - TEEC_Operation op = TeecManager::Instance().GetOperation(id); - TEEC_RequestCancellation(&op); - ReportSuccess(out); - } catch (const PlatformException& e) { - ReportError(e, out); - } -} -void LibteecInstance::TeecContextAllocateSharedMemory(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); - CHECK_EXIST(args, "contextId", out); - CHECK_EXIST(args, "size", out); - CHECK_EXIST(args, "flags", out); - - size_t size = static_cast(args.get("size").get()); - uint32_t flags = translations::SharedMemoryFlagsFromJSON(args.get("flags")); - std::string contextId = args.get("contextId").get(); - - try { - TeecContextPtr context = TeecManager::Instance().GetContext(contextId); - std::string memId = context->CreateSharedMemory(size, flags); - ReportSuccess(picojson::value(memId), out); - } catch (const PlatformException& e) { - ReportError(e, out); - } + // if success + // ReportSuccess(out); + // if error + // ReportError(out); } +void LibteecInstance::TeecContextAllocateSharedMemory(const picojson::value& args, picojson::object& out) { + CHECK_EXIST(args, "size", out) -void LibteecInstance::TeecContextRegisterSharedMemory(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); - CHECK_EXIST(args, "contextId", out); - CHECK_EXIST(args, "buffer", out); - CHECK_EXIST(args, "size", out); - CHECK_EXIST(args, "flags", out); - - void* buffer = reinterpret_cast(static_cast(args.get("buffer").get())); - size_t size = static_cast(args.get("size").get()); - uint32_t flags = static_cast(args.get("flags").get()); - std::string contextId = args.get("contextId").get(); - - try { - TeecContextPtr context = TeecManager::Instance().GetContext(contextId); - std::string memId = context->CreateSharedMemory(buffer, size, flags); - ReportSuccess(picojson::value(memId), out); - } catch (const PlatformException& e) { - ReportError(e, out); - } -} + double size = args.get("size").get(); -void LibteecInstance::TeecContextReleaseSharedMemory(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); - CHECK_EXIST(args, "contextId", out); - CHECK_EXIST(args, "memId", out); - - std::string contextId = args.get("contextId").get(); - std::string memId = args.get("memId").get(); - - try { - TeecContextPtr context = TeecManager::Instance().GetContext(contextId); - context->ReleaseSharedMemory(memId); - } catch (const PlatformException& e) { - ReportError(e, out); - } -} + // implement it -void LibteecInstance::TeecSharedMemorySetData(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); - CHECK_EXIST(args, "data", out); - CHECK_EXIST(args, "offset", out); - - std::string contextId = args.get("contextId").get(); - std::string memId = args.get("memId").get(); - DataBuffer data = translations::DataBufferFromJSON(args.get("data")); - size_t offset = static_cast(args.get("offset").get()); - - try { - TeecContextPtr context = TeecManager::Instance().GetContext(contextId); - TeecSharedMemoryPtr shmem = context->GetSharedMemory(memId); - shmem->SetData(data, offset); - ReportSuccess(out); - } catch (const PlatformException& e) { - ReportError(e, out); - } + + // if success + // ReportSuccess(out); + // if error + // ReportError(out); } +void LibteecInstance::TeecContextRegisterSharedMemory(const picojson::value& args, picojson::object& out) { + CHECK_EXIST(args, "addr", out) + CHECK_EXIST(args, "size", out) -void LibteecInstance::TeecSharedMemoryGetData(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); - CHECK_EXIST(args, "data", out); - CHECK_EXIST(args, "offset", out); - - std::string contextId = args.get("contextId").get(); - std::string memId = args.get("memId").get(); - DataBuffer data = translations::DataBufferFromJSON(args.get("data")); - size_t offset = static_cast(args.get("offset").get()); - - try { - TeecContextPtr context = TeecManager::Instance().GetContext(contextId); - TeecSharedMemoryPtr shmem = context->GetSharedMemory(memId); - shmem->GetData(data, offset); - ReportSuccess(translations::JSONFromDataBuffer(data), out); - } catch (const PlatformException& e) { - ReportError(e, out); - } + double addr = args.get("addr").get(); + double size = args.get("size").get(); + + // implement it + + + // if success + // ReportSuccess(out); + // if error + // ReportError(out); } +void LibteecInstance::TeecContextReleaseSharedMemory(const picojson::value& args, picojson::object& out) { -void LibteecInstance::TeecSessionClose(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); - CHECK_EXIST(args, "contextId", out); - CHECK_EXIST(args, "sessionId", out); - const std::string contextId = args.get("contextId").get(); - const std::string sessionId = args.get("sessionId").get(); + // implement it - try { - TeecContextPtr context = TeecManager::Instance().GetContext(contextId); - context->CloseSession(sessionId); - ReportSuccess(out); - } catch (const PlatformException& e) { - ReportError(e, out); - } + + // if success + // ReportSuccess(out); + // if error + // ReportError(out); } +void LibteecInstance::TeecSharedMemorySetData(const picojson::value& args, picojson::object& out) { + CHECK_EXIST(args, "data", out) + CHECK_EXIST(args, "offset", out) -void LibteecInstance::TeecSessionInvokeCommand(const picojson::value& args, picojson::object& out) { - CHECK_PRIVILEGE_ACCESS(kPrivilegeLibteec, &out); - CHECK_EXIST(args, "callbackId", out); - CHECK_EXIST(args, "contextId", out); - CHECK_EXIST(args, "sessionId", out); - CHECK_EXIST(args, "cmd", out); - - const double callbackId = args.get("callbackId").get(); - const std::string contextId = args.get("contextId").get(); - const std::string sessionId = args.get("sessionId").get(); - const uint32_t cmd = static_cast(args.get("cmd").get()); - - TeecContextPtr context; - TeecSessionPtr session; - uint32_t opId = 0; - - try { - context = TeecManager::Instance().GetContext(contextId); - session = context->GetSession(sessionId); - opId = TeecManager::Instance().CreateOperation(); - } catch (const PlatformException& e) { - ReportError(e, out); - } + int data = args.get("data").get(); + double offset = args.get("offset").get(); - auto invoke = [=](const std::shared_ptr& response) -> void { - try { - TeecTempMemoryAllocator allocator; - TEEC_Operation op = TeecManager::Instance().GetOperation(opId); - op.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE); - if (args.get("params").is()) { - op = translations::OperationFromJSON(args.get("params"), allocator); - } - - session->InvokeCommand(cmd, &op, NULL); - TeecManager::Instance().RemoveOperation(opId); - - picojson::object result; - result.insert(std::make_pair("cmd", picojson::value(static_cast(cmd)))); - result.insert(std::make_pair("params", translations::UpdateJSONParams(args.get("params"), op))); - ReportSuccess(picojson::value(result), response->get()); - } catch (const PlatformException& e) { - ReportError(e, response->get()); - } - }; + // implement it + + + // if success + // ReportSuccess(out); + // if error + // ReportError(out); +} +void LibteecInstance::TeecSharedMemoryGetData(const picojson::value& args, picojson::object& out) { + CHECK_EXIST(args, "data", out) + CHECK_EXIST(args, "offset", out) - auto invokeResponse = - [callbackId, this](const std::shared_ptr& response) -> void { - picojson::object& obj = response->get(); - obj.insert(std::make_pair("callbackId", picojson::value(callbackId))); - Instance::PostMessage(this, response->serialize().c_str()); - }; + int data = args.get("data").get(); + double offset = args.get("offset").get(); - auto data = std::shared_ptr(new picojson::value(picojson::object())); + // implement it - TaskQueue::GetInstance().Queue(invoke, invokeResponse, data); - ReportSuccess(picojson::value(static_cast(opId)), out); + + // if success + // ReportSuccess(out); + // if error + // ReportError(out); } + #undef CHECK_EXIST } // namespace libteec diff --git a/src/teec/libteec_instance.h b/src/teec/libteec_instance.h index c3962be..48c7b7d 100644 --- a/src/teec/libteec_instance.h +++ b/src/teec/libteec_instance.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,21 +29,13 @@ public: private: void LibTeecManagerGetContext(const picojson::value& args, picojson::object& out); - - // SharedMemory void TeecSharedMemorySetData(const picojson::value& args, picojson::object& out); - void TeecSharedMemoryGetData(const picojson::value& args, picojson::object& out); - - // Context void TeecContextReleaseSharedMemory(const picojson::value& args, picojson::object& out); void TeecContextOpenSession(const picojson::value& args, picojson::object& out); void TeecContextRegisterSharedMemory(const picojson::value& args, picojson::object& out); void TeecContextAllocateSharedMemory(const picojson::value& args, picojson::object& out); + void TeecSharedMemoryGetData(const picojson::value& args, picojson::object& out); void TeecContextRevokeCommand(const picojson::value& args, picojson::object& out); - - // Session - void TeecSessionClose(const picojson::value& args, picojson::object& out); - void TeecSessionInvokeCommand(const picojson::value& args, picojson::object& out); }; } // namespace libteec diff --git a/src/teec/teec.gyp b/src/teec/teec.gyp index 3d2bb02..a6ab469 100644 --- a/src/teec/teec.gyp +++ b/src/teec/teec.gyp @@ -12,28 +12,14 @@ 'libteec_extension.h', 'libteec_instance.cc', 'libteec_instance.h', - 'TeecManager.cc', - 'TeecManager.h', - 'TeecTranslations.cc', - 'TeecTranslations.h', - 'TeecContext.cc', - 'TeecContext.h', - 'TeecSession.cc', - 'TeecSession.h', - 'TeecSharedMemory.cc', - 'TeecSharedMemory.h', - 'TeecTempMemoryAllocator.cc', - 'TeecTempMemoryAllocator.h' ], 'include_dirs': [ '../', '<(SHARED_INTERMEDIATE_DIR)', ], 'variables': { - 'pkg-config': 'pkg-config', 'packages': [ 'webapi-plugins', - 'tef-libteec', ], }, },