SET(TARGET_SECURITY_ORIGIN_DAO_LIB "wrt-commons-security-origin-dao")
SET(TARGET_CERTIFICATE_DAO_LIB "wrt-commons-certificate-dao")
SET(TARGET_DPL_UTILS_EFL "lib${PROJECT_NAME}-utils-efl")
-SET(TARGET_DPL_ENCRYPTION "lib${PROJECT_NAME}-encryption")
SET(TARGET_I18N_DAO_RO_LIB "wrt-commons-i18n-dao-ro")
macro(configure_and_install_pkg PKG_FILE)
ADD_SUBDIRECTORY(custom_handler_dao)
ADD_SUBDIRECTORY(utils)
ADD_SUBDIRECTORY(support)
-ADD_SUBDIRECTORY(encryption)
ADD_SUBDIRECTORY(certificate_dao)
ADD_SUBDIRECTORY(i18n)
+++ /dev/null
-# Copyright (c) 2011 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 CMakeLists.txt
-# @author Soyoung Kim (sy037.kim@samsung.com)
-# @version 1.0
-# @brief
-#
-
-# Check required modules
-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(SYS_ENCRYPTION
- dlog
- openssl
- cryptsvc
- dukgenerator
- REQUIRED
-)
-
-# Add core include directories
-INCLUDE_DIRECTORIES(
- ${DPL_LOG_INCLUDE_DIR}
- ${DPL_CORE_INCLUDE_DIR}
- ${DPL_DB_INCLUDE_DIR}
- ${DPL_ENCRYPTION_INCLUDE_DIR}
-)
-
-INCLUDE_DIRECTORIES(SYSTEM ${SYS_ENCRYPTION_INCLUDE_DIRS})
-
-LINK_DIRECTORIES(
- ${SYS_ENCRYPTION_LIBRARY_DIRS}
-)
-
-# Base EFL based DPL library
-SET(DPL_ENCRYPTION_LIBRARY "${PROJECT_NAME}-encryption")
-
-# Build shared library
-
-ADD_LIBRARY(${TARGET_DPL_ENCRYPTION} SHARED
- ${DPL_ENCRYPTION_SOURCES}
-)
-
-TARGET_LINK_LIBRARIES(${TARGET_DPL_ENCRYPTION}
- ${SYS_ENCRYPTION_LIBRARIES}
- ${TARGET_DPL_EFL}
-)
-
-# Target library properties
-SET_TARGET_PROPERTIES(${TARGET_DPL_ENCRYPTION} PROPERTIES
- SOVERSION ${API_VERSION}
- VERSION ${VERSION}
- CLEAN_DIRECT_OUTPUT 1
- OUTPUT_NAME ${DPL_ENCRYPTION_LIBRARY})
-
-# Install libraries
-INSTALL(TARGETS ${TARGET_DPL_ENCRYPTION}
- DESTINATION lib)
-
-# Install detail headers
-
-INSTALL(FILES ${DPL_ENCRYPTION_HEADERS}
- DESTINATION include/dpl-efl/dpl/encryption)
-
-# Install pkgconfig script
-configure_and_install_pkg(dpl-encryption.pc)
+++ /dev/null
-prefix=/usr
-exec_prefix=${prefix}
-libdir=${prefix}/lib
-includedir=${prefix}/include
-
-Name: dpl-encryption
-Description: DPL UTILS - EFL based
-Version: @VERSION@
-Requires: dpl-efl
-Libs: -L${libdir} -ldpl-encryption
-Cflags: -I${includedir}/dpl-efl
include(utils/config.cmake)
include(localization/config.cmake)
include(support/config.cmake)
-include(encryption/config.cmake)
};
template<typename FunctionType>
-ScopeGuard<typename std::decay<FunctionType>::type>
+inline ScopeGuard<typename std::decay<FunctionType>::type>
MakeScopeGuard(FunctionType&& function)
{
return ScopeGuard<typename std::decay<FunctionType>::type>(
enum class ScopeGuardOnExit {};
template <typename FunctionType>
-ScopeGuard<typename std::decay<FunctionType>::type>
+inline ScopeGuard<typename std::decay<FunctionType>::type>
operator+(detail::ScopeGuardOnExit, FunctionType&& function)
{
return ScopeGuard<typename std::decay<FunctionType>::type>(
}
}
-// FIXME provide support for compilers not supporting variadic macros
+// FIXME provide support for compilers not supporting variadic macros;
+// instead of using variadic macros (for compatibility) we could
+// capture all by '&' (only referenced variables would be captured)
#define DPL_SCOPE_EXIT(...) \
auto DPL_ANONYMOUS_VARIABLE(DPL_SCOPE_EXIT_STATE) \
= ::DPL::detail::ScopeGuardOnExit() + [__VA_ARGS__]()
+++ /dev/null
-# Copyright (c) 2011 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 config.cmake
-# @author Soyoung Kim(sy037.kim@samsung.com)
-# @version 1.0
-# @brief
-#
-
-SET(DPL_ENCRYPTION_SOURCES
- ${PROJECT_SOURCE_DIR}/modules/encryption/src/resource_encryption.cpp
- ${PROJECT_SOURCE_DIR}/modules/encryption/src/resource_decryption.cpp
- PARENT_SCOPE
-)
-
-
-SET(DPL_ENCRYPTION_HEADERS
- ${PROJECT_SOURCE_DIR}/modules/encryption/include/dpl/encryption/resource_encryption.h
- ${PROJECT_SOURCE_DIR}/modules/encryption/include/dpl/encryption/resource_decryption.h
- PARENT_SCOPE
-)
-
-SET(DPL_ENCRYPTION_INCLUDE_DIR
- ${PROJECT_SOURCE_DIR}/modules/encryption/include
- PARENT_SCOPE
-)
+++ /dev/null
-/*
- * Copyright (c) 2011 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 resource_decryption.h
- * @author Soyoung Kim (sy037.kim@samsung.com)
- * @version 1.0
- * @brief Header file for resource decryption
- */
-#ifndef RESOURCE_DECRYPTION_H
-#define RESOURCE_DECRYPTION_H
-
-#include <string.h>
-#include <string>
-#include <openssl/aes.h>
-#include <openssl/sha.h>
-#include <dpl/exception.h>
-
-extern char** calculate(char*pappId, int idLen, int keyLen);
-
-namespace WRTDecryptor {
-class ResourceDecryptor
-{
- public:
- class Exception
- {
- public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(Base, GetDecKeyFailed)
- DECLARE_EXCEPTION_TYPE(Base, EncryptionFailed)
- };
-
- ResourceDecryptor();
- ResourceDecryptor(std::string userKey);
- virtual ~ResourceDecryptor();
-
- void SetDecryptionKey(std::string userKey);
- void GetDecryptedChunk(unsigned char* inBuf,
- unsigned char* decBuf,
- size_t chunkSize);
-
- private:
- AES_KEY* GetDecryptionKey();
- AES_KEY m_decKey;
-};
-} //namespace WRTDecryptor
-
-#endif /* RESOURCE_DECRYPTION_H */
+++ /dev/null
-/*
- * Copyright (c) 2011 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 resource_encryption.h
- * @author Soyoung Kim (sy037.kim@samsung.com)
- * @version 1.0
- * @brief Header file for resource encryption
- */
-#ifndef RESOURCE_ENCRYPTION_H
-#define RESOURCE_ENCRYPTION_H
-
-#include <string.h>
-#include <string>
-#include <openssl/aes.h>
-#include <openssl/sha.h>
-#include <dpl/exception.h>
-
-extern char** calculate(char*pappId, int idLen, int keyLen);
-
-namespace WRTEncryptor {
-class ResourceEncryptor
-{
- public:
- class Exception
- {
- public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateEncKeyFailed)
- DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateDecKeyFailed)
- DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateEncKeyFileFailed)
- DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateDecKeyFileFailed)
- DECLARE_EXCEPTION_TYPE(DPL::Exception, EncryptionFailed)
- };
-
- ResourceEncryptor();
- virtual ~ResourceEncryptor();
-
- int GetBlockSize(int inSize);
- void CreateEncryptionKey(std::string userKey);
- void EncryptChunk(unsigned char* inputBuf, unsigned char* encBuf, size_t
- chunkSize);
-
- private:
- AES_KEY GetEncryptionkey();
- AES_KEY m_encKey;
-};
-} //namespace WRTEncryptor
-
-#endif /* RESOURCE_DECRYPTION_H */
+++ /dev/null
-/*
- * Copyright (c) 2011 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 resource_decryption.cpp
- * @author Soyoung Kim (sy037.kim@samsung.com)
- * @version 1.0
- * @brief Implementation file for resource decryption
- */
-#include <stddef.h>
-#include <dpl/encryption/resource_decryption.h>
-
-#include <fcntl.h>
-#include <string>
-#include <dpl/log/log.h>
-#include <dpl/exception.h>
-#include <dukgen.h>
-
-namespace {
-#define BITS_SIZE 128
-#define KEY_SIZE 16
-}
-namespace WRTDecryptor {
-ResourceDecryptor::ResourceDecryptor()
-{
- LogDebug("Started Decryption");
-}
-
-ResourceDecryptor::ResourceDecryptor(std::string userKey)
-{
- LogDebug("Finished Decryption");
- SetDecryptionKey(userKey);
-}
-
-ResourceDecryptor::~ResourceDecryptor()
-{}
-
-void ResourceDecryptor::SetDecryptionKey(std::string userKey)
-{
- if (userKey.empty()) {
- return;
- }
-
- char* pKey = GetDeviceUniqueKey(const_cast<char*>(userKey.c_str()),
- userKey.size(), KEY_SIZE);
-
- unsigned char *key = reinterpret_cast<unsigned char*>(pKey);
-
- if (0 > AES_set_decrypt_key(key, BITS_SIZE, &m_decKey)) {
- ThrowMsg(ResourceDecryptor::Exception::GetDecKeyFailed,
- "Failed to create decryption key");
- }
-}
-
-AES_KEY* ResourceDecryptor::GetDecryptionKey()
-{
- return &m_decKey;
-}
-
-void ResourceDecryptor::GetDecryptedChunk(unsigned char*
- inBuf,
- unsigned char* decBuf,
- size_t inBufSize)
-{
- Assert(decBuf);
- if (decBuf == NULL) {
- ThrowMsg(ResourceDecryptor::Exception::EncryptionFailed,
- "Failed to Get Decryption Chunk");
- }
- unsigned char ivec[16] = { 0, };
-
- AES_cbc_encrypt(inBuf, decBuf, inBufSize, &m_decKey, ivec, AES_DECRYPT);
- LogDebug("Success decryption");
-}
-} //namespace WRTDecryptor
+++ /dev/null
-/*
- * Copyright (c) 2011 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 resource_encryption.cpp
- * @author Soyoung Kim (sy037.kim@samsung.com)
- * @version 1.0
- * @brief Implementation file for resource encryption
- */
-#include <stddef.h>
-#include <dpl/encryption/resource_encryption.h>
-
-#include <fcntl.h>
-#include <dpl/log/log.h>
-#include <dukgen.h>
-
-namespace {
-#define BITS_SIZE 128
-#define KEY_SIZE 16
-}
-namespace WRTEncryptor {
-ResourceEncryptor::ResourceEncryptor()
-{
- LogDebug("Started Encrytion");
-}
-
-ResourceEncryptor::~ResourceEncryptor()
-{
- LogDebug("Finished Encrytion");
-}
-
-int ResourceEncryptor::GetBlockSize(int inSize)
-{
- if ((inSize % AES_BLOCK_SIZE) != 0) {
- return (( inSize / AES_BLOCK_SIZE) + 1) * AES_BLOCK_SIZE;
- }
- return inSize;
-}
-
-void ResourceEncryptor::CreateEncryptionKey(std::string userKey)
-{
- if (userKey.empty()) {
- return;
- }
-
- char* pKey = GetDeviceUniqueKey(const_cast<char*>(userKey.c_str()),
- userKey.size(), KEY_SIZE);
- unsigned char *key = reinterpret_cast<unsigned char*>(pKey);
-
- if (0 > AES_set_encrypt_key(key, BITS_SIZE, &m_encKey)) {
- ThrowMsg(ResourceEncryptor::Exception::CreateEncKeyFailed,
- "Failed to create encryption key");
- }
- LogDebug("Success to create ecryption and decryption key");
-}
-
-AES_KEY ResourceEncryptor::GetEncryptionkey()
-{
- return m_encKey;
-}
-
-void ResourceEncryptor::EncryptChunk(unsigned char*
- inputBuf,
- unsigned char* encBuf,
- size_t chunkSize)
-{
- Assert(inputBuf);
- Assert(encBuf);
-
- unsigned char ivec[16] = { 0, };
-
- AES_cbc_encrypt(inputBuf, encBuf, chunkSize, &m_encKey, ivec, AES_ENCRYPT);
-}
-} //namespace ResourceEnc
#define COLOR_END "\e[0m"
#define COLOR_TAG "\e[0m"
+// default TAG
+#undef LOG_TAG
+#define LOG_TAG "WRT_UNDEFINED"
+
#ifdef WRT_LOG
#undef LOG_TAG
#define LOG_TAG "WRT"
${PROJECT_SOURCE_DIR}/modules/test/src/test_results_collector.cpp
${PROJECT_SOURCE_DIR}/modules/test/src/test_runner.cpp
${PROJECT_SOURCE_DIR}/modules/test/src/test_runner_child.cpp
+ ${PROJECT_SOURCE_DIR}/modules/test/src/process_pipe.cpp
PARENT_SCOPE
)
${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_results_collector.h
${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_runner.h
${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_runner_child.h
+ ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/process_pipe.h
PARENT_SCOPE
)
--- /dev/null
+/*
+ * Copyright (c) 2013 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 process_pipe.h
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation pipe from process
+ */
+#ifndef PROCESS_PIPE_H
+#define PROCESS_PIPE_H
+
+#include <dpl/file_input.h>
+#include <dpl/exception.h>
+
+#include <cstdio>
+
+namespace DPL {
+
+class ProcessPipe : public FileInput
+{
+public:
+ class Exception
+ {
+ public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, DoubleOpen)
+ };
+
+ enum class PipeErrorPolicy
+ {
+ NONE,
+ OFF,
+ PIPE
+ };
+
+ explicit ProcessPipe(PipeErrorPolicy err = PipeErrorPolicy::NONE);
+ virtual ~ProcessPipe();
+
+ void Open(const std::string &command);
+ void Close();
+
+private:
+ FILE * m_file;
+ PipeErrorPolicy m_errPolicy;
+};
+
+}
+
+#endif // PROCESS_PIPE_H
--- /dev/null
+/*
+ * Copyright (c) 2013 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 process_pipe.cpp
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation pipe from process
+ */
+
+#include<dpl/test/process_pipe.h>
+#include<dpl/log/log.h>
+
+namespace DPL {
+
+ProcessPipe::ProcessPipe(PipeErrorPolicy err) : m_file(NULL), m_errPolicy(err)
+{
+}
+
+ProcessPipe::~ProcessPipe()
+{
+}
+
+void ProcessPipe::Open(const std::string & command)
+{
+ if(m_file != NULL)
+ {
+ ThrowMsg(Exception::DoubleOpen, "Trying to open pipe second time. Close it first");
+ }
+
+ std::string stdErrRedirection;
+ switch(m_errPolicy)
+ {
+ case PipeErrorPolicy::NONE: break;
+ case PipeErrorPolicy::OFF: stdErrRedirection = " 2>/dev/null"; break;
+ case PipeErrorPolicy::PIPE: stdErrRedirection = " 2>&1"; break;
+ default: break;
+ }
+
+ std::string fcommand = command + stdErrRedirection;
+ FILE * file = popen(fcommand.c_str(), "r");
+
+ // Throw an exception if an error occurred
+ if (file == NULL) {
+ ThrowMsg(FileInput::Exception::OpenFailed, fcommand);
+ }
+
+ // Save new descriptor
+ m_file = file;
+ m_fd = fileno(m_file);
+
+ LogPedantic("Opened pipe: " << fcommand);
+}
+
+void ProcessPipe::Close()
+{
+ if (m_fd == -1) {
+ return;
+ }
+
+ if (pclose(m_file) == -1) {
+ Throw(FileInput::Exception::CloseFailed);
+ }
+
+ m_fd = -1;
+ m_file = NULL;
+
+ LogPedantic("Closed pipe");
+}
+
+}
if (code == 0) {
throw TestRunner::TestFailed(message);
}
+ if (code == 2) {
+ throw TestRunner::TestFailed("Ignored");
+ }
} else {
// child code
} catch (DPL::Test::TestRunner::TestFailed &e) {
msg = e.GetMessage();
code = 0;
+ } catch (DPL::Test::TestRunner::Ignored &e) {
+ msg = e.GetMessage();
+ code = 2;
} catch (...) { // Pokemon Catch... cache them all...
msg = "unhandled exeception";
code = 0;
// hard drive. What's why we cannot check any iri with file schema.
const char *IRI_IGNORED_SCHEME[] = { "file://", "widget://", "app://", "tel:",
- "sms:", "mmsto:", "mailto:", "data:", "blob:",
+ "sms:", "smsto:", "mmsto:", "mailto:", "data:", "blob:",
"tizen-service:", 0 };
const DPL::String SCHEMA_HTTP = DPL::FromUTF8String("http");
return tzAppId;
}
+void WidgetDAO::updateTizenAppId(
+ const TizenAppId & fromAppId,
+ const TizenAppId & toAppId)
+{
+ SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+ {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+
+ ScopedTransaction transaction(&WrtDatabase::interface());
+ if (!isWidgetInstalled(fromAppId)) {
+ ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+ "Cannot find widget. tzAppId: " << fromAppId);
+ }
+
+ WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+ select->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
+
+ WidgetInfo::Row row = select->GetSingleRow();
+
+ //WidgetInfo::Row row;
+ row.Set_tizen_appid(toAppId);
+
+ WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface())
+ update->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
+ update->Values(row);
+ update->Execute();
+
+ transaction.Commit();
+ }
+ SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to update appid")
+}
+
void WidgetDAO::registerWidgetInternal(
const TizenAppId & tzAppId,
const WidgetRegisterInfo &widgetRegInfo,
registerWidgetSecuritySettings(widgetHandle);
}
-void WidgetDAO::registerOrUpdateWidget(
- const TizenAppId & widgetName,
- const WidgetRegisterInfo &widgetRegInfo,
- const IWidgetSecurity &widgetSecurity)
-{
- LogDebug("Reregistering widget");
- SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
- {
- DPL::DB::ORM::wrt::ScopedTransaction transaction(
- &WrtDatabase::interface());
-
- unregisterWidgetInternal(widgetName);
- registerWidgetInternal(widgetName, widgetRegInfo, widgetSecurity);
- transaction.Commit();
- }
- SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
-}
-
-void WidgetDAO::backupAndUpdateWidget(
- const TizenAppId & oldAppId,
- const TizenAppId & newAppId,
- const WidgetRegisterInfo &widgetRegInfo,
- const IWidgetSecurity &widgetSecurity)
-{
- LogDebug("Backup and Register widget");
- SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
- {
- DPL::DB::ORM::wrt::ScopedTransaction transaction(
- &WrtDatabase::interface());
-
- updateWidgetAppIdInternal(newAppId, oldAppId);
- registerWidgetInternal(newAppId, widgetRegInfo, widgetSecurity);
- transaction.Commit();
- }
- SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
-}
-
-void WidgetDAO::restoreUpdateWidget(
- const TizenAppId & oldAppId,
- const TizenAppId & newAppId)
-{
- LogDebug("restore widget");
- SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
- {
- DPL::DB::ORM::wrt::ScopedTransaction transaction(
- &WrtDatabase::interface());
-
- unregisterWidgetInternal(newAppId);
- updateWidgetAppIdInternal(oldAppId, newAppId);
- transaction.Commit();
- }
- SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
-}
-
#define DO_INSERT(row, table) \
{ \
WRT_DB_INSERT(insert, table, &WrtDatabase::interface()) \
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
}
-void WidgetDAO::unregisterWidget(WrtDB::DbWidgetHandle handle)
-{
- LogDebug("Unregistering widget from DB. Handle: " << handle);
- SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
- {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
- ScopedTransaction transaction(&WrtDatabase::interface());
-
- // Delete from table Widget Info
- WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
- del->Where(Equals<WidgetInfo::app_id>(handle));
- del->Execute();
-
- transaction.Commit();
- }
- SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
-}
-
void WidgetDAO::unregisterWidgetInternal(
const TizenAppId & tzAppId)
{
// Deleting in other tables is done via "delete cascade" in SQL
}
-void WidgetDAO::updateWidgetAppIdInternal(
- const TizenAppId & fromAppId,
- const TizenAppId & toAppId)
-{
- SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
- {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
-
- ScopedTransaction transaction(&WrtDatabase::interface());
- if (!isWidgetInstalled(fromAppId)) {
- ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
- "Cannot find widget. tzAppId: " << fromAppId);
- }
-
- WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
- select->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
-
- WidgetInfo::Row row = select->GetSingleRow();
-
- //WidgetInfo::Row row;
- row.Set_tizen_appid(toAppId);
-
- WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface())
- update->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
- update->Values(row);
- update->Execute();
-
- transaction.Commit();
- }
- SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to update appid")
-}
-
#undef DO_INSERT
#undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
}
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
}
+
+TizenPkgId getTizenPkgIdByAppId(const TizenAppId tzAppid)
+{
+ LogDebug("Getting TizenPkgId by TizenAppId: " << tzAppid);
+
+ SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+ {
+ WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+ select->Where(Equals<WidgetInfo::tizen_appid>(tzAppid));
+ WidgetInfo::Select::RowList rowList = select->GetRowList();
+
+ if (rowList.empty()) {
+ ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+ "Failed to get widget by tizen appId");
+ }
+ TizenPkgId tzPkgid = rowList.front().Get_tizen_pkgid();
+
+ return tzPkgid;
+ }
+ SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed get pkgId")
+}
} // namespace
IWidgetSecurity::~IWidgetSecurity()
return getTizenPkgIdByHandle(m_widgetHandle);
}
+TizenPkgId WidgetDAOReadOnly::getTzPkgId(const DbWidgetHandle handle)
+{
+ return getTizenPkgIdByHandle(handle);
+}
+
+TizenPkgId WidgetDAOReadOnly::getTzPkgId(const TizenAppId tzAppid)
+{
+ return getTizenPkgIdByAppId(tzAppid);
+}
+
PropertyDAOReadOnly::WidgetPropertyKeyList
WidgetDAOReadOnly::getPropertyKeyList() const
{
*/
TizenPkgId getTzPkgId() const;
+ static TizenPkgId getTzPkgId(const DbWidgetHandle handle);
+ static TizenPkgId getTzPkgId(const TizenAppId tzAppid);
/**
* This method returns the root directory of widget resource.
static DbWidgetDAOReadOnlyList getWidgetList();
/**
- * This method removes a widget's information from EmDB.
- *
- * @see RegisterWidget()
- * @param[in] widgetHandle widget's app id
- * @return true if succeed, false if fail.
- */
- static void unregisterWidget(DbWidgetHandle widgetHandle);
-
- /**
* This method gets author's infomation of a widget which is parsed from
* configiration document.
*
const WidgetRegisterInfo &pWidgetRegisterInfo,
const IWidgetSecurity &widgetSecurity);
- /**
- * This method re-registers the widget information to the DB when it is
- * installed.
- *
- * It performs unregistration and new registration of widget in db in one
- * transaction.
- *
- * @see WidgetRegisterInfo
- * @param[in] tzAppId Widget tizen app id that will be registered.
- * @param[in] pWidgetRegisterInfo Specified the widget's information
- * needed to be registered.
- * @param[in] widgetSecurity Widget's security certificates.
- */
- static void registerOrUpdateWidget(
- const TizenAppId & tzAppId,
- const WidgetRegisterInfo &widgetRegInfo,
- const IWidgetSecurity &widgetSecurity);
-
- /* This method backup widget information and update new widget information
- * for restore widget information
- */
- static void backupAndUpdateWidget(
- const TizenAppId & oldAppId,
- const TizenAppId & newAppId,
- const WidgetRegisterInfo &widgetRegInfo,
- const IWidgetSecurity &widgetSecurity);
-
- static void restoreUpdateWidget(
- const TizenAppId & oldAppId,
- const TizenAppId & newAppId);
-
+ static void updateTizenAppId(const TizenAppId & fromAppId,
+ const TizenAppId & toAppId);
/**
* This method removes a widget's information from EmDB.
*
*/
static void unregisterWidget(const TizenAppId & tzAppId);
- static void unregisterWidget(WrtDB::DbWidgetHandle handle) __attribute__((
- deprecated));
-
/* This method removes widget property
*/
void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);
const IWidgetSecurity &widgetSecurity,
const DPL::Optional<DbWidgetHandle> handle =
DPL::Optional<DbWidgetHandle>());
- static void unregisterWidgetInternal(
- const TizenAppId & tzAppId);
-
- static void updateWidgetAppIdInternal(
- const TizenAppId & fromAppId,
- const TizenAppId & toAppId);
-
+ static void unregisterWidgetInternal(const TizenAppId & tzAppId);
static void insertAppControlInfo(DbWidgetHandle handle,
- DPL::String src,
- DPL::String operation,
- DPL::String uri,
- DPL::String mime,
- unsigned index,
- unsigned disposition);
+ DPL::String src,
+ DPL::String operation,
+ DPL::String uri,
+ DPL::String mime,
+ unsigned index,
+ unsigned disposition);
};
} // namespace WrtDB
#git:framework/web/wrt-commons
Name: wrt-commons
Summary: Wrt common library
-Version: 0.2.139
+Version: 0.2.145
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(libiri)
BuildRequires: pkgconfig(libidn)
-BuildRequires: pkgconfig(cryptsvc)
-BuildRequires: pkgconfig(dukgenerator)
BuildRequires: pkgconfig(minizip)
-Requires: libcryptsvc
%description
Wrt common library
%endif
%build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
export LDFLAGS+="-Wl,--rpath=%{_libdir} -Wl,--hash-style=both -Wl,--as-needed"
tizenAppId), "Widget is not registered");
//success full update
- WidgetDAO::registerOrUpdateWidget(tizenAppId, regInfo2, sec);
+ WidgetDAO::updateTizenAppId(tizenAppId, L"backup");
+ WidgetDAO::registerWidget(tizenAppId, regInfo2, sec);
+ WidgetDAO::unregisterWidget(L"backup");
RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
tizenAppId), "Widget is not reregistered");
WidgetDAO dao(tizenAppId);
RUNNER_ASSERT_MSG(
*dao.getAuthorName() == L"BBB", "Data widget was not updated");
+
WidgetDAO::unregisterWidget(tizenAppId);
}
# @brief
#
-SET(TARGET_NAME "wrt-commons-tests-test-runner-child")
+SET(TARGET_NAME "wrt-commons-tests-test")
# Set DPL tests sources
SET(DPL_TESTS_UTIL_SOURCES
${TESTS_DIR}/test/main.cpp
${TESTS_DIR}/test/runner_child.cpp
+ ${TESTS_DIR}/test/test_process_pipe.cpp
)
#WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_NAME} ${TARGET_DPL_UTILS_EFL})
* @brief Implementation file for test cases for engine internal tests
*/
#include <dpl/test/test_runner_child.h>
+#include <dpl/log/log.h>
#include <unistd.h>
#include <vector>
#include <sys/types.h>
#include <signal.h>
+
+namespace {
+enum class TestResult
+{
+ PASS,
+ FAIL,
+ IGNORED,
+ TIMEOUT,
+ UNKNOWN
+};
+}
+
+#define RUNNER_CHILD_TEST_EXPECT(name, result, message) \
+ static void testExpectFunction##name(); \
+ RUNNER_TEST(name) \
+ { \
+ TestResult eResult = result; \
+ TestResult rResult = TestResult::UNKNOWN; \
+ std::string eMessage = message; \
+ Try \
+ { \
+ DPL::Test::RunChildProc(&testExpectFunction##name); \
+ } \
+ Catch(DPL::Test::TestRunner::TestFailed) \
+ { \
+ std::string rMessage = _rethrown_exception.GetMessage(); \
+ size_t pos = rMessage.find(")"); \
+ if(pos != std::string::npos && pos+2 <= rMessage.length()) \
+ { \
+ rMessage = rMessage.substr(pos+2); \
+ } \
+ if(rMessage == "Timeout") \
+ { \
+ rResult = TestResult::TIMEOUT; \
+ } \
+ else if(rMessage == "Ignored") \
+ { \
+ rResult = TestResult::IGNORED; \
+ } \
+ else if(rMessage == eMessage) \
+ { \
+ rResult = TestResult::FAIL; \
+ } \
+ else \
+ { \
+ RUNNER_ASSERT_MSG(false, "Fail message do not matches"); \
+ } \
+ } \
+ if(rResult == TestResult::UNKNOWN) \
+ { \
+ rResult = TestResult::PASS; \
+ } \
+ RUNNER_ASSERT_MSG(eResult == rResult, "Expected other result"); \
+ } \
+ void testExpectFunction##name() \
+
+
RUNNER_TEST_GROUP_INIT(DPL_TESTS_TEST_CHILD)
-RUNNER_TEST(t00_pass)
+RUNNER_CHILD_TEST_EXPECT(t00_pass, TestResult::PASS, "")
{
RUNNER_ASSERT_MSG(1, "This test should pass");
}
-RUNNER_CHILD_TEST(t01_pass)
+RUNNER_CHILD_TEST_EXPECT(t01_pass, TestResult::PASS, "")
{
RUNNER_ASSERT_MSG(1, "This test should pass");
}
-RUNNER_CHILD_TEST(t02_fail)
+RUNNER_CHILD_TEST_EXPECT(t02_fail, TestResult::FAIL, "This test should fail")
{
RUNNER_ASSERT_MSG(0, "This test should fail");
}
-RUNNER_CHILD_TEST(t03_fail_timeout)
+RUNNER_CHILD_TEST_EXPECT(t03_fail_timeout, TestResult::TIMEOUT, "")
{
sleep(20);
RUNNER_ASSERT_MSG(1, "This test should fail");
}
-RUNNER_CHILD_TEST(t04_fail)
+RUNNER_CHILD_TEST_EXPECT(t04_fail, TestResult::FAIL, "This test should fail")
{
RUNNER_ASSERT_MSG(1, "This test should fail");
RUNNER_ASSERT_MSG(1, "This test should fail");
RUNNER_ASSERT_MSG(0, "This test should fail");
}
-RUNNER_CHILD_TEST(t05_fail_child_died)
+RUNNER_CHILD_TEST_EXPECT(t05_fail_child_died, TestResult::FAIL, "Reading pipe error")
{
kill(getpid(), SIGKILL);
RUNNER_ASSERT_MSG(1, "This test should fail");
}
-RUNNER_CHILD_TEST(t06_pass_8_second_test)
+RUNNER_CHILD_TEST_EXPECT(t06_pass_8_second_test, TestResult::PASS, "")
{
sleep(8);
RUNNER_ASSERT_MSG(1, "This test should pass");
}
-RUNNER_CHILD_TEST(t07_fail_unknown_exception)
+RUNNER_CHILD_TEST_EXPECT(t07_fail_unknown_exception, TestResult::FAIL, "unhandled exeception")
{
throw("hello");
}
-RUNNER_CHILD_TEST(t08_fail_unknown_exception)
+RUNNER_CHILD_TEST_EXPECT(t08_fail_unknown_exception, TestResult::FAIL, "unhandled exeception")
{
throw(1);
}
-RUNNER_CHILD_TEST(t09_fail_you_should_see_text_normal_assert)
+RUNNER_CHILD_TEST_EXPECT(t09_fail_you_should_see_text_normal_assert, TestResult::FAIL, "Normal assert")
{
RUNNER_ASSERT_MSG(0, "Normal assert");
}
-RUNNER_CHILD_TEST(t10_pass)
+RUNNER_CHILD_TEST_EXPECT(t10_pass, TestResult::PASS, "")
{
RUNNER_ASSERT_MSG(1, "Normal assert");
}
+RUNNER_CHILD_TEST_EXPECT(t11_ignore, TestResult::IGNORED, "Test ignored")
+{
+ RUNNER_IGNORED_MSG("Test ignored");
+}
+
+
--- /dev/null
+/*
+ * Copyright (c) 2013 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 test_process_pipe.cpp
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation file of ProcessPipe tests
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/test/process_pipe.h>
+#include <dpl/binary_queue.h>
+#include <dpl/log/log.h>
+
+#include <cstring>
+
+using namespace DPL;
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+namespace {
+void readAll(ProcessPipe & npp, BinaryQueue & result)
+{
+ do
+ {
+ BinaryQueueAutoPtr dataptr = npp.Read(4096);
+
+ RUNNER_ASSERT_MSG(dataptr.get() != NULL, "Cannot read from pipe subprocess");
+
+ LogDebug("Size: " << dataptr->Size());
+
+ if(dataptr->Empty()) break;
+ result.AppendMoveFrom(*dataptr);
+ }
+ while(true);
+}
+}
+
+RUNNER_TEST(ProcessPipe_echo)
+{
+ ProcessPipe npp;
+ npp.Open("echo -e \"Test echo text\\nAnd new line\"");
+ BinaryQueue result;
+ readAll(npp, result);
+ npp.Close();
+
+ char buffer[100] = "";
+ result.FlattenConsume(buffer, 99);
+
+ RUNNER_ASSERT_MSG(strcmp(buffer, "Test echo text\nAnd new line\n") == 0, "Echoed text in not equal");
+}
+
+RUNNER_TEST(ProcessPipe_double_open)
+{
+ ProcessPipe npp;
+ npp.Open("echo \"Test \"");
+ Try
+ {
+ npp.Open("echo \"Test\"");
+ }
+ Catch(DPL::ProcessPipe::Exception::DoubleOpen)
+ {
+ npp.Close();
+ return;
+ }
+ npp.Close();
+ RUNNER_ASSERT_MSG(false, "DoubleOpen not thrown");
+}
+
+RUNNER_TEST(ProcessPipe_double_close)
+{
+ ProcessPipe npp;
+ npp.Open("echo \"Test invalid\"");
+ npp.Close();
+ Try
+ {
+ npp.Close();
+ }
+ Catch(DPL::Exception)
+ {
+ RUNNER_ASSERT_MSG(false, "Second Close throws exception");
+ }
+}
+
+RUNNER_TEST(ProcessPipe_pipeerror_off)
+{
+ ProcessPipe npp(ProcessPipe::PipeErrorPolicy::OFF);
+ npp.Open("ls /nonexistingdirectory");
+ BinaryQueue result;
+ readAll(npp, result); //TODO: fix this test
+ npp.Close();
+}
+
+RUNNER_TEST(ProcessPipe_pipeerror_pipe)
+{
+ //ls output dependent...
+ ProcessPipe npp(ProcessPipe::PipeErrorPolicy::PIPE);
+ npp.Open("ls /nonexistingdirectory");
+ BinaryQueue result;
+ readAll(npp, result);
+ npp.Close();
+ char buffer[100] = "";
+ result.FlattenConsume(buffer, 99);
+
+ RUNNER_ASSERT_MSG(strcmp(buffer, "ls: cannot access /nonexistingdirectory: No such file or directory\n") == 0, "Ls error text in not equal");
+}