Update wrt-commons_0.2.54
authorjihoon.chung <jihoon.chung@samsung.com>
Wed, 29 Aug 2012 06:24:06 +0000 (15:24 +0900)
committerjihoon.chung <jihoon.chung@samsung.com>
Wed, 29 Aug 2012 06:24:06 +0000 (15:24 +0900)
20 files changed:
CMakeLists.txt
build/CMakeLists.txt
build/encryption/CMakeLists.txt [new file with mode: 0644]
build/encryption/dpl-encryption.pc.in [new file with mode: 0644]
debian/changelog
modules/CMakeLists.txt
modules/core/src/main.cpp
modules/encryption/config.cmake [new file with mode: 0644]
modules/encryption/include/dpl/encryption/resource_decryption.h [new file with mode: 0644]
modules/encryption/include/dpl/encryption/resource_encryption.h [new file with mode: 0644]
modules/encryption/src/resource_decryption.cpp [new file with mode: 0644]
modules/encryption/src/resource_encryption.cpp [new file with mode: 0644]
modules/test/src/test_results_collector.cpp
modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/dao/widget_dao_read_only.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h
modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h
modules/widget_dao/orm/wrt_db
packaging/wrt-commons.spec

index e0122e6..cd2d925 100644 (file)
@@ -178,6 +178,7 @@ SET(TARGET_AUTO_SAVE_DAO_LIB "wrt-commons-auto-save-dao")
 SET(TARGET_AUTO_SAVE_DAO_RW_LIB "wrt-commons-auto-save-dao-rw")
 SET(TARGET_AUTO_SAVE_DAO_RO_LIB "wrt-commons-auto-save-dao-ro")
 SET(TARGET_DPL_UTILS_EFL "lib${PROJECT_NAME}-utils-efl")
+SET(TARGET_DPL_ENCRYPTION "lib${PROJECT_NAME}-encryption")
 
 macro(configure_and_install_pkg PKG_FILE)
     CONFIGURE_FILE(${PKG_FILE}.in ${PKG_FILE} @ONLY)
index bc09abc..3cd6b53 100644 (file)
@@ -31,3 +31,4 @@ ADD_SUBDIRECTORY(auto_save_dao)
 ADD_SUBDIRECTORY(popup)
 ADD_SUBDIRECTORY(utils)
 ADD_SUBDIRECTORY(support)
+ADD_SUBDIRECTORY(encryption)
diff --git a/build/encryption/CMakeLists.txt b/build/encryption/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7994b27
--- /dev/null
@@ -0,0 +1,73 @@
+# 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
+    REQUIRED
+)
+
+# Add core include directories
+INCLUDE_DIRECTORIES(
+    ${DPL_LOG_INCLUDE_DIR}
+    ${DPL_CORE_INCLUDE_DIR}
+    ${DPL_DB_INCLUDE_DIR}
+    ${SYS_ENCRYPTION_INCLUDE_DIRS}
+    ${DPL_ENCRYPTION_INCLUDE_DIR}
+)
+
+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)
diff --git a/build/encryption/dpl-encryption.pc.in b/build/encryption/dpl-encryption.pc.in
new file mode 100644 (file)
index 0000000..dfddda3
--- /dev/null
@@ -0,0 +1,11 @@
+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
index 06e8bfb..dbc7c88 100644 (file)
@@ -1,3 +1,14 @@
+wrt-commons (0.2.54) unstable; urgency=low
+
+  * [common] Add XML test collector
+  * [common] Add encryption api
+  * [Engine] Fix for wrt-popup
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.54
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 29 Aug 2012 13:37:28 +0900
+
 wrt-commons (0.2.53) unstable; urgency=low
 
   * Added new build type for code coverage
index 204fd74..750aa57 100644 (file)
@@ -33,3 +33,4 @@ include(popup/config.cmake)
 include(utils/config.cmake)
 include(localization/config.cmake)
 include(support/config.cmake)
+include(encryption/config.cmake)
index 4e8078c..0268d6f 100644 (file)
@@ -96,6 +96,9 @@ Main::~Main()
     ecore_main_fd_handler_del(m_invokerHandler);
     m_invokerHandler = NULL;
 
+    //set old ecore select function, because after ecore_shutdown() call,
+    //it is being called once again and it may crash.
+    ecore_main_loop_select_func_set(m_oldEcoreSelect);
     // Decrement ECORE init count
     // We do not need ecore routines any more
     ecore_shutdown();
diff --git a/modules/encryption/config.cmake b/modules/encryption/config.cmake
new file mode 100644 (file)
index 0000000..5188ecb
--- /dev/null
@@ -0,0 +1,38 @@
+# 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
+)
diff --git a/modules/encryption/include/dpl/encryption/resource_decryption.h b/modules/encryption/include/dpl/encryption/resource_decryption.h
new file mode 100644 (file)
index 0000000..c22b1d2
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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>
+
+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 */
diff --git a/modules/encryption/include/dpl/encryption/resource_encryption.h b/modules/encryption/include/dpl/encryption/resource_encryption.h
new file mode 100644 (file)
index 0000000..ffc82c2
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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>
+
+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 */
diff --git a/modules/encryption/src/resource_decryption.cpp b/modules/encryption/src/resource_decryption.cpp
new file mode 100644 (file)
index 0000000..499d82e
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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 <dpl/encryption/resource_decryption.h>
+
+#include <fcntl.h>
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/exception.h>
+
+namespace {
+inline std::string GetDefaultEncryptKeyPath() {
+    return "/opt/apps/widget/data/";
+}
+}
+namespace WRTDecryptor{
+ResourceDecryptor::ResourceDecryptor() :
+    m_decKey(NULL)
+{
+    LogDebug("Started Decryption");
+}
+
+ResourceDecryptor::ResourceDecryptor(std::string userKey) :
+    m_decKey(NULL)
+{
+    LogDebug("Finished Decryption");
+    SetDecryptionKey(userKey);
+}
+
+ResourceDecryptor::~ResourceDecryptor()
+{
+    delete m_decKey;
+}
+
+void ResourceDecryptor::SetDecryptionKey(std::string userKey)
+{
+    /* TODO : get key from secure storage */
+    std::string keyPath = GetDefaultEncryptKeyPath() + userKey + "_dec";
+    LogDebug("Description Key path : " << keyPath);
+
+    FILE* fp = fopen(keyPath.c_str(), "rb");
+    if (fp == NULL) {
+        ThrowMsg(ResourceDecryptor::Exception::GetDecKeyFailed,
+                "Failed to get decryption key");
+    }
+    m_decKey = new AES_KEY;
+    fread(m_decKey, 1, sizeof(AES_KEY),fp);
+    fclose(fp);
+}
+
+AES_KEY* ResourceDecryptor::GetDecryptionKey()
+{
+    return m_decKey;
+}
+
+void ResourceDecryptor::GetDecryptedChunk(unsigned char*
+        inBuf, unsigned char* decBuf, size_t inBufSize)
+{
+    Assert(decBuf);
+    Assert(m_decKey);
+    if (decBuf == NULL || m_decKey == 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
diff --git a/modules/encryption/src/resource_encryption.cpp b/modules/encryption/src/resource_encryption.cpp
new file mode 100644 (file)
index 0000000..62201bf
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * 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 <dpl/encryption/resource_encryption.h>
+
+#include <fcntl.h>
+#include <dpl/log/log.h>
+
+namespace {
+#define BITS_SIZE 128
+const char* ENCRYPTION_FILE = "_enc";
+const char* DECRYPTION_FILE = "_dec";
+
+inline std::string GetDefaultEncryptKeyPath() {
+    return "/opt/apps/widget/data";
+}
+}
+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;
+    }
+
+    AES_KEY decKey;
+    const unsigned char* key = reinterpret_cast<unsigned char*>(
+                                    const_cast<char*>(userKey.c_str()));
+
+    if ( 0 > AES_set_encrypt_key(key, BITS_SIZE, &m_encKey)) {
+        ThrowMsg(ResourceEncryptor::Exception::CreateEncKeyFailed,
+                "Failed to create encryption key");
+    }
+    if ( 0 > AES_set_decrypt_key(key, BITS_SIZE, &decKey)) {
+        ThrowMsg(ResourceEncryptor::Exception::CreateDecKeyFailed,
+                "Failed to create decryption key");
+    }
+
+    std::string encPath, decPath;
+
+    encPath = GetDefaultEncryptKeyPath() + "/" + userKey + ENCRYPTION_FILE;
+    decPath = GetDefaultEncryptKeyPath() + "/" + userKey + DECRYPTION_FILE;
+
+    /* TODO : save keys to secure storage */
+    LogDebug("Encryption Key path " << encPath);
+    LogDebug("Decryption Key path " << decPath);
+
+    FILE* encFp = fopen(encPath.c_str(), "wb");
+    if (encFp == NULL) {
+        ThrowMsg(ResourceEncryptor::Exception::CreateEncKeyFileFailed,
+                "Failed to save encryption key");
+    }
+    fwrite(&m_encKey, 1, sizeof(m_encKey), encFp);
+    fclose(encFp);
+
+    FILE* decFp = fopen(decPath.c_str(), "wb");
+    if (decFp == NULL) {
+        ThrowMsg(ResourceEncryptor::Exception::CreateDecKeyFileFailed,
+                "Failed to save decryption key");
+    }
+
+    fwrite(&decKey, 1, sizeof(decKey), decFp);
+    fclose(decFp);
+    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
index 1e65877..e36e868 100644 (file)
@@ -30,6 +30,7 @@
 #include <cstdio>
 #include <fstream>
 #include <sstream>
+#include <cstdlib>
 
 namespace DPL
 {
@@ -40,6 +41,7 @@ namespace
 {
 const char *DEFAULT_HTML_FILE_NAME = "index.html";
 const char *DEFAULT_TAP_FILE_NAME = "results.tap";
+const char *DEFAULT_XML_FILE_NAME = "results.xml";
 
 class Statistic
 {
@@ -47,7 +49,6 @@ class Statistic
     Statistic() :
         m_failed(0),
         m_ignored(0),
-        m_todo(0),
         m_passed(0),
         m_count(0)
     {
@@ -60,7 +61,6 @@ class Statistic
             case TestResultsCollectorBase::FailStatus::INTERNAL:
             case TestResultsCollectorBase::FailStatus::FAILED:   ++m_failed; break;
             case TestResultsCollectorBase::FailStatus::IGNORED:  ++m_ignored; break;
-            case TestResultsCollectorBase::FailStatus::TODO:     ++m_todo; break;
             case TestResultsCollectorBase::FailStatus::NONE:     ++m_passed; break;
             default:
                 Assert(false && "Bad FailStatus");
@@ -71,7 +71,6 @@ class Statistic
     size_t GetPassed() const { return m_passed; }
     size_t GetSuccesed() const { return m_passed; }
     size_t GetFailed() const { return m_failed; }
-    size_t GetTODO() const { return m_todo; }
     size_t GetIgnored() const { return m_ignored; }
     float GetPassedOrIgnoredPercend() const
     {
@@ -85,7 +84,6 @@ class Statistic
   private:
     size_t m_failed;
     size_t m_ignored;
-    size_t m_todo;
     size_t m_passed;
     size_t m_count;
 };
@@ -132,8 +130,6 @@ class ConsoleCollector
                 PrintfErrorMessage(  " FAILED ", reason, true); break;
             case TestResultsCollectorBase::FailStatus::IGNORED:
                 PrintfIgnoredMessage("Ignored ", reason, true); break;
-            case TestResultsCollectorBase::FailStatus::TODO:
-                PrintfTODOMessage(   "  TODO  ", reason, true); break;
             case TestResultsCollectorBase::FailStatus::INTERNAL:
                 PrintfErrorMessage(  "INTERNAL", reason, true); break;
             default:
@@ -164,27 +160,6 @@ class ConsoleCollector
         }
     }
 
-    void PrintfTODOMessage(const char* type,
-                           const std::string& message,
-                           bool verbosity)
-    {
-        using namespace DPL::Colors::Text;
-        if (verbosity) {
-            printf("[%s%s%s] %s%s%s\n",
-                   BOLD_WHITE_BEGIN,
-                   type,
-                   BOLD_WHITE_END,
-                   BOLD_GOLD_BEGIN,
-                   message.c_str(),
-                   BOLD_GOLD_END);
-        } else {
-            printf("[%s%s%s]\n",
-                   BOLD_WHITE_BEGIN,
-                   type,
-                   BOLD_WHITE_END);
-        }
-    }
-
     void PrintfIgnoredMessage(const char* type,
                               const std::string& message,
                               bool verbosity)
@@ -211,12 +186,9 @@ class ConsoleCollector
         using namespace DPL::Colors::Text;
         printf("\n%sResults [%s]: %s\n", BOLD_GREEN_BEGIN, title.c_str(), BOLD_GREEN_END);
         printf("%s%s%3d%s\n", CYAN_BEGIN,     "Total tests:            ", stats.GetTotal(), CYAN_END);
-        printf("%s%s%3d%s\n", CYAN_BEGIN,     "Succeeded or ignored:   ", stats.GetPassed() + stats.GetIgnored(), CYAN_END);
-        printf("  %s%s%3d%s\n", CYAN_BEGIN,     "Succeeded:            ", stats.GetPassed(), CYAN_END);
-        printf("  %s%s%3d%s\n", CYAN_BEGIN,     "Ignored:              ", stats.GetIgnored(), CYAN_END);
-        printf("%s%s%3d%s\n", CYAN_BEGIN,     "Failed:                 ", stats.GetFailed(), CYAN_END);
-        printf("%s%s%3d%s\n", CYAN_BEGIN,     "Todo:                   ", stats.GetTODO(), CYAN_END);
-        printf("%s%s%3.0f%%%s\n", CYAN_BEGIN, "Succeeded or ignored %: ", stats.GetPassedOrIgnoredPercend(), CYAN_END);
+        printf("  %s%s%3d%s\n", CYAN_BEGIN,   "Succeeded:            ", stats.GetPassed(), CYAN_END);
+        printf("  %s%s%3d%s\n", CYAN_BEGIN,   "Failed:               ", stats.GetFailed(), CYAN_END);
+        printf("  %s%s%3d%s\n", CYAN_BEGIN,   "Ignored:              ", stats.GetIgnored(), CYAN_END);
     }
 
     Statistic m_stats;
@@ -318,8 +290,6 @@ class HtmlCollector
                 PrintfErrorMessage(  " FAILED ", reason, true); break;
             case TestResultsCollectorBase::FailStatus::IGNORED:
                 PrintfIgnoredMessage("Ignored ", reason, true); break;
-            case TestResultsCollectorBase::FailStatus::TODO:
-                PrintfTODOMessage(   "  TODO  ", reason, true); break;
             case TestResultsCollectorBase::FailStatus::INTERNAL:
                 PrintfErrorMessage(  "INTERNAL", reason, true); break;
             default:
@@ -352,29 +322,6 @@ class HtmlCollector
         }
     }
 
-    void PrintfTODOMessage(const char* type,
-                           const std::string& message,
-                           bool verbosity)
-    {
-        using namespace DPL::Colors::Html;
-        if (verbosity) {
-            fprintf(m_fp.Get(),
-                    "[%s%s%s] %s%s%s\n",
-                    BOLD_WHITE_BEGIN,
-                    type,
-                    BOLD_WHITE_END,
-                    BOLD_GOLD_BEGIN,
-                    message.c_str(),
-                    BOLD_GOLD_END);
-        } else {
-            fprintf(m_fp.Get(),
-                    "[%s%s%s]\n",
-                    BOLD_WHITE_BEGIN,
-                    type,
-                    BOLD_WHITE_END);
-        }
-    }
-
     void PrintfIgnoredMessage(const char* type,
                               const std::string& message,
                               bool verbosity)
@@ -404,12 +351,9 @@ class HtmlCollector
         using namespace DPL::Colors::Html;
         fprintf(m_fp.Get(), "\n%sResults [%s]:%s\n", BOLD_GREEN_BEGIN, name.c_str(), BOLD_GREEN_END);
         fprintf(m_fp.Get(), "%s%s%3d%s\n", CYAN_BEGIN,     "Total tests:            ", stats.GetTotal(), CYAN_END);
-        fprintf(m_fp.Get(), "%s%s%3d%s\n", CYAN_BEGIN,     "Succeeded or ignored:   ", stats.GetPassed() + stats.GetIgnored(), CYAN_END);
-        fprintf(m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,     "Succeeded:            ", stats.GetPassed(), CYAN_END);
-        fprintf(m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,     "Ignored:              ", stats.GetIgnored(), CYAN_END);
-        fprintf(m_fp.Get(), "%s%s%3d%s\n", CYAN_BEGIN,     "Failed:                 ", stats.GetFailed(), CYAN_END);
-        fprintf(m_fp.Get(), "%s%s%3d%s\n", CYAN_BEGIN,     "Todo:                   ", stats.GetTODO(), CYAN_END);
-        fprintf(m_fp.Get(), "%s%s%3.0f%%%s\n", CYAN_BEGIN, "Succeeded or ignored %: ", stats.GetPassedOrIgnoredPercend(), CYAN_END);
+        fprintf(m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,   "Succeeded:            ", stats.GetPassed(), CYAN_END);
+        fprintf(m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,   "Failed:               ", stats.GetFailed(), CYAN_END);
+        fprintf(m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,   "Ignored:              ", stats.GetIgnored(), CYAN_END);
     }
 
     std::string m_filename;
@@ -424,6 +368,241 @@ TestResultsCollectorBase* HtmlCollector::Constructor()
     return new HtmlCollector();
 }
 
+
+class XmlCollector
+    : public TestResultsCollectorBase
+{
+  public:
+    static TestResultsCollectorBase* Constructor();
+
+  private:
+    XmlCollector() : m_filename(DEFAULT_XML_FILE_NAME) {}
+
+    virtual void CollectCurrentTestGroupName(const std::string& name)
+    {
+        std::string groupHeader;
+        groupHeader.append("\n\t<testsuite name=\"");
+        groupHeader.append(EscapeSpecialCharacters(name));
+        groupHeader.append("\">\n\t\t<testcase name=\"unknown\" status=\"FAILED\">\n");
+        groupHeader.append("\t\t\t<failure type=\"FAILED\" message=\"segmentation fault\"/>\n");
+        groupHeader.append("\t\t</testcase>\n\t</testsuite>");
+        size_t pos = m_outputBuffer.find("</testsuites>");
+        m_outputBuffer.insert(pos - 1, groupHeader);
+        m_currentGroup = name;
+        fseek(m_fp.Get(), 0L, SEEK_SET);
+        fprintf(m_fp.Get(), "%s", m_outputBuffer.c_str());
+        fflush(m_fp.Get());
+
+    }
+
+    virtual bool Configure()
+    {
+        m_fp.Reset(fopen (m_filename.c_str(), "w"));
+        if (!m_fp) {
+            LogPedantic("Could not open file " << m_filename << " for writing");
+            return false;
+        }
+        return true;
+    }
+
+    virtual std::string CollectorSpecificHelp() const
+    {
+        return "--file=<filename> - name of file for output\n"
+               "                    default - results.xml\n";
+    }
+
+    virtual void Start()
+    {
+        Assert(!!m_fp && "File handle must not be null");
+        m_outputBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
+        m_outputBuffer.append("<testsuites>\n</testsuites>");
+        fseek(m_fp.Get(), 0L, SEEK_SET);
+        fprintf(m_fp.Get(), "%s", m_outputBuffer.c_str());
+        fflush(m_fp.Get());
+
+    }
+
+    virtual void Finish()
+    {
+        // Show result
+        FOREACH(group, m_groupsStats) {
+            PrintStats(group->first, group->second);
+        }
+
+        size_t posBegin = m_outputBuffer.find("<testcase name=\"unknown\"");
+        size_t posEnd = m_outputBuffer.find("</testcase>", posBegin);
+        m_outputBuffer.erase(posBegin - 3, posEnd - posBegin + sizeof("</testcase>") + 2);
+        remove(m_filename.c_str());
+        m_fp.Reset(fopen (m_filename.c_str(), "w"));
+        Assert(!!m_fp && "File handle must not be null");
+        fseek(m_fp.Get(), 0L, SEEK_SET);
+        fprintf(m_fp.Get(),"%s", m_outputBuffer.c_str());
+        fflush(m_fp.Get());
+    }
+
+    virtual bool ParseCollectorSpecificArg(const std::string& arg)
+    {
+        const std::string argname = "--file=";
+        if (0 == arg.find(argname)) {
+            m_filename = arg.substr(argname.size());
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    virtual void CollectResult(const std::string& id,
+                               const std::string& /*description*/,
+                               const FailStatus::Type status = FailStatus::NONE,
+                               const std::string& reason = "")
+    {
+        m_resultBuffer.erase();
+        m_resultBuffer.append("\t\t<testcase name=\"");
+        m_resultBuffer.append(EscapeSpecialCharacters(id));
+        m_resultBuffer.append("\"");
+        switch(status) {
+            case TestResultsCollectorBase::FailStatus::NONE:
+                m_resultBuffer.append(" status=\"OK\"/>\n");
+                break;
+            case TestResultsCollectorBase::FailStatus::FAILED:
+                m_resultBuffer.append(" status=\"FAILED\">\n\t\t\t<failure");
+                PrintfErrorMessage("FAILED", EscapeSpecialCharacters(reason), true);
+                m_resultBuffer.append("\t\t</testcase>\n");
+                break;
+            case TestResultsCollectorBase::FailStatus::IGNORED:
+                m_resultBuffer.append(" status=\"Ignored\">\n");
+                PrintfIgnoredMessage("Ignored", EscapeSpecialCharacters(reason), true);
+                m_resultBuffer.append("\t\t</testcase>\n");
+                break;
+            case TestResultsCollectorBase::FailStatus::INTERNAL:
+                m_resultBuffer.append(" status=\"INTERNAL\">\n\t\t\t<failure");
+                PrintfErrorMessage("INTERNAL", EscapeSpecialCharacters(reason), true);
+                m_resultBuffer.append("\t\t</testcase>");
+                break;
+            default:
+                Assert(false && "Bad status");
+        }
+        size_t pos = m_outputBuffer.find("<testcase name=\"unknown\"");
+        m_outputBuffer.insert(pos - 2, m_resultBuffer);
+        fseek(m_fp.Get(), 0L, SEEK_SET);
+        fprintf(m_fp.Get(), "%s", m_outputBuffer.c_str());
+        fflush(m_fp.Get());
+        m_groupsStats[m_currentGroup].AddTest(status);
+        m_stats.AddTest(status);
+
+    }
+
+    void PrintfErrorMessage(const char* type,
+                            const std::string& message,
+                            bool verbosity)
+    {
+        if (verbosity) {
+            m_resultBuffer.append(" type=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(type));
+            m_resultBuffer.append("\" message=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(message));
+            m_resultBuffer.append("\"/>\n");
+
+        } else {
+
+            m_resultBuffer.append(" type=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(type));
+            m_resultBuffer.append("\"/>\n");
+        }
+    }
+
+    void PrintfIgnoredMessage(const char* type,
+                              const std::string& message,
+                              bool verbosity)
+    {
+        if (verbosity) {
+            m_resultBuffer.append("\t\t\t<skipped type=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(type));
+            m_resultBuffer.append("\" message=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(message));
+            m_resultBuffer.append("\"/>\n");
+        } else {
+
+            m_resultBuffer.append("\t\t\t<skipped type=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(type));
+            m_resultBuffer.append("\"/>\n");
+        }
+    }
+
+    void PrintStats(const std::string& name, const Statistic& stats)
+    {
+        std::stringstream totalStats;
+        totalStats << " tests=\"";
+        totalStats << stats.GetTotal();
+        totalStats << "\" failures=\"";
+        totalStats << stats.GetFailed();
+        totalStats << "\" skipped=\"";
+        totalStats << stats.GetIgnored();
+        totalStats << "\"";
+        std::string suiteHeader;
+        suiteHeader.append("<testsuite name=\"");
+        suiteHeader.append(EscapeSpecialCharacters(name));
+        size_t pos = m_outputBuffer.find(suiteHeader);
+        m_outputBuffer.insert(pos+suiteHeader.size()+1,totalStats.str());
+    }
+
+    std::string EscapeSpecialCharacters(std::string s)
+    {
+        for(unsigned int i = 0; i < s.size();){
+            switch(s[i]){
+            case '"':
+                s.erase(i,1);
+                s.insert(i, "&quot;");
+                i+=6;
+                break;
+
+            case '&':
+                s.erase(i,1);
+                s.insert(i, "&amp;");
+                i+=5;
+                break;
+
+            case '<':
+                s.erase(i,1);
+                s.insert(i, "&lt;");
+                i+=4;
+                break;
+
+            case '>':
+                s.erase(i,1);
+                s.insert(i, "&gt;");
+                i+=4;
+                break;
+
+            case '\'':
+                s.erase(i,1);
+                s.insert(i, "&#39;");
+                i+=5;
+                break;
+            default:
+                ++i;
+                break;
+            }
+        }
+        return s;
+    }
+
+    std::string m_filename;
+    ScopedFClose m_fp;
+    Statistic m_stats;
+    std::string m_currentGroup;
+    std::map<std::string, Statistic> m_groupsStats;
+    std::string m_outputBuffer;
+    std::string m_resultBuffer;
+};
+
+TestResultsCollectorBase* XmlCollector::Constructor()
+{
+    return new XmlCollector();
+}
+
+
+
 class CSVCollector
     : public TestResultsCollectorBase
 {
@@ -452,7 +631,6 @@ class CSVCollector
             case TestResultsCollectorBase::FailStatus::NONE: statusMsg = "OK"; break;
             case TestResultsCollectorBase::FailStatus::FAILED: statusMsg = "FAILED"; break;
             case TestResultsCollectorBase::FailStatus::IGNORED: statusMsg = "IGNORED"; break;
-            case TestResultsCollectorBase::FailStatus::TODO:  statusMsg = "TODO"; break;
             case TestResultsCollectorBase::FailStatus::INTERNAL: statusMsg = "FAILED"; break;
             default:
                 Assert(false && "Bad status");
@@ -549,11 +727,6 @@ class TAPCollector
                 m_collectedData << " # skip " << reason;
                 endTAPLine();
                 break;
-            case TestResultsCollectorBase::FailStatus::TODO:
-                LogBasicTAP(false, id, description);
-                m_collectedData << " # TODO " << reason;
-                endTAPLine();
-                break;
             case TestResultsCollectorBase::FailStatus::INTERNAL:
                 LogBasicTAP(true, id, description);
                 endTAPLine();
@@ -646,6 +819,9 @@ int RegisterCollectorConstructors()
     TestResultsCollectorBase::RegisterCollectorConstructor(
         "tap",
         &TAPCollector::Constructor);
+    TestResultsCollectorBase::RegisterCollectorConstructor(
+        "xml",
+        &XmlCollector::Constructor);
 
     return 0;
 }
index 84925ed..e04fd47 100644 (file)
@@ -164,6 +164,8 @@ void WidgetDAO::registerWidget(
 
         registerAppService(widgetHandle, widgetRegInfo);
 
+        registerEncryptedResouceInfo(widgetHandle, widgetRegInfo);
+
         transaction.Commit();
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
@@ -533,6 +535,23 @@ void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
     }
 }
 
+void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo)
+{
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::wrt;
+
+    FOREACH(it, regInfo.encryptedFiles)
+    {
+        EncryptedResourceList::Row row;
+        row.Set_app_id(widgetHandle);
+        row.Set_resource(it->fileName);
+        row.Set_size(it->fileSize);
+
+        DO_INSERT(row, EncryptedResourceList)
+    }
+}
+
 #undef DO_INSERT
 
 void WidgetDAO::unregisterWidget(DbWidgetHandle widgetHandle)
index 9e5f71e..a89233b 100644 (file)
@@ -1085,6 +1085,25 @@ PkgType WidgetDAOReadOnly::getPkgType() const
     return PkgType(static_cast<PackagingType>(*result));
 }
 
+void WidgetDAOReadOnly::getEncryptedFileList(EncryptedFileList& filesList) const
+{
+    //TODO check widget existance
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::wrt;
+    WRT_DB_SELECT(select, EncryptedResourceList, &WrtDatabase::interface())
+    select->Where(Equals<EncryptedResourceList::app_id>(m_widgetHandle));
+
+    typedef std::list<DPL::DB::ORM::wrt::EncryptedResourceList::Row> RowList;
+    RowList list = select->GetRowList();
+
+    FOREACH(it, list) {
+        EncryptedFileInfo info;
+        info.fileName = it->Get_resource();
+        info.fileSize = it->Get_size();
+        filesList.insert(info);
+    }
+}
+
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END
 #undef CHECK_WIDGET_EXISTENCE
index 019953a..1b8d466 100644 (file)
@@ -131,10 +131,33 @@ struct WidgetAccessInfo
     }
 };
 
+struct EncryptedFileInfo
+{
+    DPL::String fileName;
+    int fileSize;
+
+    bool operator==(const EncryptedFileInfo& info) const
+    {
+        return fileName == info.fileName;
+    }
+
+    bool operator==(const DPL::String& file) const
+    {
+        return fileName == file;
+    }
+
+    bool operator< (const EncryptedFileInfo& info) const
+    {
+        return fileName < info.fileName;
+    }
+};
+
 typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
 
 typedef std::list<DPL::String> WindowModeList;
 
+typedef std::set<EncryptedFileInfo> EncryptedFileList;
+
 /**
  * @brief Widget configuration parameter key
  */
index 62fbe6e..db1de98 100644 (file)
@@ -173,6 +173,7 @@ struct WidgetRegisterInfo
     DPL::OptionalString pkgname;
     time_t installedTime;
     PkgType pType;
+    EncryptedFileList encryptedFiles;
 };
 
 typedef std::list<std::string> CertificateChainList;
@@ -716,6 +717,8 @@ class WidgetDAOReadOnly
                                                 records in DB table.
      */
     PkgType getPkgType() const;
+
+    void getEncryptedFileList(EncryptedFileList& filesList) const;
 };
 
 } // namespace WrtDB
index 0802046..cdc1f73 100644 (file)
@@ -160,6 +160,9 @@ class WidgetDAO : public WidgetDAOReadOnly
     static void registerAppService(
             DbWidgetHandle widgetHandle,
             const WidgetRegisterInfo &regInfo);
+    static void registerEncryptedResouceInfo(
+            DbWidgetHandle widgetHandle,
+            const WidgetRegisterInfo &regInfo);
 };
 
 } // namespace WrtDB
index 5ccae07..9d969f2 100644 (file)
@@ -282,6 +282,16 @@ CREATE_TABLE(WidgetWhiteURIList)
     COLUMN_NOT_NULL(subdomain_access,    INT,        CHECK(subdomain_access between 0 and 1))
 CREATE_TABLE_END()
 
+CREATE_TABLE(EncryptedResourceList)
+    COLUMN_NOT_NULL(app_id,         INT,)
+    COLUMN_NOT_NULL(resource,       TEXT,)
+    COLUMN_NOT_NULL(size,           INT,)
+
+    TABLE_CONSTRAINTS(
+        FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
+    )
+CREATE_TABLE_END()
+
 SQL(
     INSERT INTO WidgetWhiteURIList VALUES("http://samsung.com", 1);
     INSERT INTO WidgetWhiteURIList VALUES("http://orange.fr", 1);
index f599252..0d0898d 100644 (file)
@@ -1,7 +1,7 @@
-#sbs-git:slp/pkgs/w/wrt-commons wrt-commons 0.2.53
+#sbs-git:slp/pkgs/w/wrt-commons wrt-commons 0.2.54
 Name:       wrt-commons
 Summary:    Wrt common library
-Version:    0.2.53
+Version:    0.2.54
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0