[Release] wrt-commons_0.2.102 submit/sdk/20130307.002312
authorJihoon Chung <jihoon.chung@samsung.com>
Thu, 7 Mar 2013 00:22:52 +0000 (09:22 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Thu, 7 Mar 2013 00:22:52 +0000 (09:22 +0900)
Change-Id: Ida97bdb923d82dd488fb6a9e6319ddbec6f0b45b

16 files changed:
debian/changelog
modules/core/config.cmake
modules/core/include/dpl/scoped_dir.h [new file with mode: 0644]
modules/core/include/dpl/string.h
modules/core/src/scoped_dir.cpp [new file with mode: 0644]
modules/security_origin_dao/dao/security_origin_dao_types.cpp
modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao_types.h
modules/utils/config.cmake
modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/vconf_config.h
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h
packaging/wrt-commons.spec
tests/core/CMakeLists.txt
tests/core/test_scoped_dir.cpp [new file with mode: 0644]
tests/core/test_static_block.cpp
tests/core/test_string.cpp

index d3991a0588dfb53b14a92d402f9f3fb972a2b3a9..8cff8142c9560a0348c678439354fa517328a75b 100644 (file)
@@ -1,3 +1,12 @@
+wrt-commons (0.2.102) unstable; urgency=low
+
+  * DPL path join for class Path to be introduced
+  * tests - Return value not used
+  * Fix App-control Supports : Registration routine was added
+  * Remove web storage & filesystem usage code
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 07 Mar 2013 09:03:04 +0900
+
 wrt-commons (0.2.101) unstable; urgency=low
 
   * CSP report only support
index b681dd59a4d0b595e2a7b5aa74a27666ee843016..b929c35c72535211d627359a0c8a8f107e5ba194 100644 (file)
@@ -45,6 +45,7 @@ SET(DPL_CORE_SOURCES
     ${PROJECT_SOURCE_DIR}/modules/core/src/once.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/read_write_mutex.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/recursive_mutex.cpp
+    ${PROJECT_SOURCE_DIR}/modules/core/src/scoped_dir.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/serialization.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/single_instance.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/singleton.cpp
@@ -112,6 +113,7 @@ SET(DPL_CORE_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/scoped_resource.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/scoped_array.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/scoped_close.h
+    ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/scoped_dir.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/scoped_fclose.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/scoped_free.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/scoped_ptr.h
diff --git a/modules/core/include/dpl/scoped_dir.h b/modules/core/include/dpl/scoped_dir.h
new file mode 100644 (file)
index 0000000..b10b4cc
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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        scoped_dir.h
+ * @author      Iwanek Tomasz (t.iwanek@smasung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of scoped directory existence
+ */
+
+#ifndef DPL_SCOPED_DIR_H
+#define DPL_SCOPED_DIR_H
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <string>
+#include <dpl/scoped_resource.h>
+
+namespace DPL {
+
+struct ScopedDirPolicy
+{
+    typedef std::string Type;
+    static Type NullValue();
+    static void Destroy(Type ptr);
+};
+
+class ScopedDir : public ScopedResource<ScopedDirPolicy>
+{
+    typedef ScopedDirPolicy Policy;
+    typedef ScopedResource<Policy> BaseType;
+
+  public:
+    explicit ScopedDir(const std::string & str = Policy::NullValue(), mode_t mode = S_IRWXU|S_IRGRP|S_IXGRP);
+};
+} // namespace DPL
+
+#endif // DPL_SCOPED_DIR_H
index 59cd5e1749d65fdc07ede8813084aa102a571f8d..31132c13ab8e30554a9e7527a9f544b7487edb2f 100644 (file)
@@ -25,6 +25,7 @@
 #include <dpl/char_traits.h>
 #include <string>
 #include <ostream>
+#include <numeric>
 
 namespace DPL {
 // @brief DPL string
@@ -105,6 +106,33 @@ void Tokenize(const StringType& str,
         nextSearchStart = pos + 1;
     }
 }
+
+namespace Utils {
+
+template<typename T> class ConcatFunc : public std::binary_function<T, T, T>
+{
+public:
+    explicit ConcatFunc(const T & val) : m_delim(val) {}
+    T operator()(const T & arg1, const T & arg2) const
+    {
+        return arg1 + m_delim + arg2;
+    }
+private:
+    T m_delim;
+};
+
+}
+
+template<typename ForwardIterator>
+typename ForwardIterator::value_type Join(ForwardIterator begin, ForwardIterator end, typename ForwardIterator::value_type delim)
+{
+    typedef typename ForwardIterator::value_type value;
+    if(begin == end) return value();
+    Utils::ConcatFunc<value> func(delim);
+    ForwardIterator init = begin;
+    return std::accumulate(++begin, end, *init, func);
+}
+
 } //namespace DPL
 
 std::ostream& operator<<(std::ostream& aStream, const DPL::String& aString);
diff --git a/modules/core/src/scoped_dir.cpp b/modules/core/src/scoped_dir.cpp
new file mode 100644 (file)
index 0000000..2639f7a
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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        scoped_dir.cpp
+ * @author      Iwanek Tomasz (t.iwanek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation scoped directory
+ */
+#include <dpl/scoped_dir.h>
+#include <dpl/log/log.h>
+
+#include <fts.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+namespace {
+
+bool removeRecusive(const char * path)
+{
+    FTS *fts;
+    FTSENT *ftsent;
+    bool rv = true;
+    char * const paths[] = { const_cast<char * const>(path), NULL };
+    if ((fts = fts_open(paths, FTS_PHYSICAL | FTS_NOCHDIR, NULL)) == NULL) {
+        return false;
+    }
+    while ((ftsent = fts_read(fts)) != NULL) {
+        switch (ftsent->fts_info) {
+        case FTS_D:
+            break;
+        case FTS_DP:
+            if (rmdir(ftsent->fts_accpath) != 0) {
+                rv = false;
+            }
+            break;
+        case FTS_DC:
+        case FTS_F:
+        case FTS_NSOK:
+        case FTS_SL:
+        case FTS_SLNONE:
+        case FTS_DEFAULT:
+            if (unlink(ftsent->fts_accpath) != 0) {
+                rv = false;
+            }
+            break;
+        case FTS_NS:
+            rv = false;
+            break;
+        case FTS_DOT:
+        case FTS_DNR:
+        case FTS_ERR:
+        default:
+            rv = false;
+            break;
+        }
+    }
+    if (fts_close(fts) == -1) {
+        rv = false;
+    }
+    return rv;
+}
+
+}
+
+namespace DPL {
+
+ScopedDirPolicy::Type ScopedDirPolicy::NullValue()
+{
+    return std::string();
+}
+
+void ScopedDirPolicy::Destroy(Type str)
+{
+    if(!str.empty())
+    {
+        bool status = removeRecusive(str.c_str());
+        if(!status)
+        {
+            LogError("Error while removing recursively: " << str);
+        }
+    }
+}
+
+ScopedDir::ScopedDir(const std::string & str, mode_t mode) : BaseType(str)
+{
+    if(!str.empty())
+    {
+        mkdir(str.c_str(), mode);
+    }
+}
+
+} // namespace DPL
+
index 639c2b7ec4a8c704140fac46633bd29f7dd2eeff..eaecc4b136dae651a23333602b83567931796f15 100644 (file)
@@ -28,8 +28,6 @@
 namespace SecurityOriginDB {
 const std::map<std::string, Feature> g_W3CPrivilegeTextMap = {
     {"http://tizen.org/privilege/location",     FEATURE_GEOLOCATION},
-    {"http://tizen.org/privilege/notification", FEATURE_WEB_NOTIFICATION},
-    {"http://tizen.org/privilege/unlimitedstorage",     FEATURE_WEB_DATABASE},
-    {"http://tizen.org/privilege/filesystem.write",      FEATURE_FILE_SYSTEM_ACCESS}
+    {"http://tizen.org/privilege/notification", FEATURE_WEB_NOTIFICATION}
 };
 } // namespace SecurityOriginDB
index 28ead7864523f895d786b868121bbee83a43ec1b..bcb068147fe11a180165c1f112b201cd1036982c 100644 (file)
@@ -35,9 +35,7 @@ enum Feature
     FEATURE_START = 0,
     FEATURE_GEOLOCATION = 0,
     FEATURE_WEB_NOTIFICATION,
-    FEATURE_WEB_DATABASE,
-    FEATURE_FILE_SYSTEM_ACCESS,
-    FEATURE_END = FEATURE_FILE_SYSTEM_ACCESS
+    FEATURE_END = FEATURE_WEB_NOTIFICATION
 };
 
 enum Result
index 2b0beca797aa0a6f0e3ce4d09e9aa22cabd802c0..aac2fcebf23036b09e594874bc1d7246eb964e66 100644 (file)
@@ -30,7 +30,6 @@ SET(DPL_UTILS_SOURCES
     PARENT_SCOPE
 )
 
-
 SET(DPL_UTILS_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/bash_utils.h
     ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/folder_size.h
index a58c4786bdd0056b60b6422feff426ee3aa15385..51c4627bc6d183fcda7bb7d0398cc1d67f8c3d99 100644 (file)
@@ -695,6 +695,26 @@ void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
     }
 }
 
+void WidgetDAO::insertApplicationServiceInfo(DbWidgetHandle handle,
+                                             DPL::String src,
+                                             DPL::String operation,
+                                             DPL::String scheme,
+                                             DPL::String mime)
+{
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::wrt;
+
+    ApplicationServiceInfo::Row row;
+
+    row.Set_app_id(handle);
+    row.Set_src(src);
+    row.Set_operation(operation);
+    row.Set_scheme(scheme);
+    row.Set_mime(mime);
+
+    DO_INSERT(row, ApplicationServiceInfo);
+}
+
 void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
                                    const WidgetRegisterInfo &regInfo)
 {
@@ -702,6 +722,7 @@ void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
     using namespace DPL::DB::ORM::wrt;
     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
 
+    // appServiceList
     FOREACH(ASIt, widgetConfigurationInfo.appServiceList)
     {
         ApplicationServiceInfo::Row row;
@@ -714,6 +735,57 @@ void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
 
         DO_INSERT(row, ApplicationServiceInfo)
     }
+
+    // appControlList
+    FOREACH(appControl_it, widgetConfigurationInfo.appControlList)
+    {
+        DPL::String src       = appControl_it->m_src;
+        DPL::String operation = appControl_it->m_operation;
+
+        if (!appControl_it->m_uriList.empty())
+        {
+            FOREACH(uri_it, appControl_it->m_uriList)
+            {
+                DPL::String scheme = *uri_it;
+
+                if (!appControl_it->m_mimeList.empty())
+                {
+                    FOREACH(mime_it, appControl_it->m_mimeList)
+                    {
+                        DPL::String mime = *mime_it;
+
+                        insertApplicationServiceInfo(widgetHandle, src, operation, scheme, mime);
+                    }
+                }
+                else
+                {
+                    DPL::String mime = L"";
+
+                    insertApplicationServiceInfo(widgetHandle, src, operation, scheme, mime);
+                }
+            }
+        }
+        else
+        {
+            DPL::String scheme = L"";
+
+            if (!appControl_it->m_mimeList.empty())
+            {
+                FOREACH(mime_it, appControl_it->m_mimeList)
+                {
+                    DPL::String mime = *mime_it;
+
+                    insertApplicationServiceInfo(widgetHandle, src, operation, scheme, mime);
+                }
+            }
+            else
+            {
+                DPL::String mime = L"";
+
+                insertApplicationServiceInfo(widgetHandle, src, operation, scheme, mime);
+            }
+        }
+    }
 }
 
 void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
index 5f232623477120d29e74e3915e97eb220ab7a709..92451418ecb56cbffe39a59f0ddf70e51df84204 100644 (file)
@@ -65,24 +65,6 @@ inline std::string GetVconfKeyWebNotificationUsage(DPL::String tzPkgId)
                .GetFullPath();
 }
 
-inline std::string GetVconfKeyWebDatabaseUsage(DPL::String tzPkgId)
-{
-    return PathBuilder()
-               .Append(GlobalConfig::GetVconfKeyPrefixPath())
-               .Append(DPL::ToUTF8String(tzPkgId))
-               .Concat(GlobalConfig::GetVconfKeyWebDatabaseUsagePath())
-               .GetFullPath();
-}
-
-inline std::string GetVconfKeyFilesystemUsage(DPL::String tzPkgId)
-{
-    return PathBuilder()
-               .Append(GlobalConfig::GetVconfKeyPrefixPath())
-               .Append(DPL::ToUTF8String(tzPkgId))
-               .Concat(GlobalConfig::GetVconfKeyFilesystemUsagePath())
-               .GetFullPath();
-}
-
 inline std::string GetVconfKeyMemorySavingMode(DPL::String tzPkgId)
 {
     return PathBuilder()
index 5f059dbb8f4397887f1e56f5a45e2fe3e495329b..0c37d5152b3f0e32fc8b35ee61395d7a51d7d42c 100644 (file)
@@ -221,6 +221,12 @@ class WidgetDAO : public WidgetDAOReadOnly
             DPL::Optional<DbWidgetHandle>());
     static void unregisterWidgetInternal(
         const TizenAppId & tzAppId);
+
+    static void insertApplicationServiceInfo(DbWidgetHandle handle,
+                                             DPL::String src,
+                                             DPL::String operation,
+                                             DPL::String scheme,
+                                             DPL::String mime);
 };
 } // namespace WrtDB
 
index 8ef3064b7db9c4daaf02b16d068a48f2eef28e67..b0720498c0ddc4e58e8116947382e459f5aae657 100644 (file)
@@ -1,7 +1,7 @@
-#git:framework/web/wrt-commons wrt-commons 0.2.101.1
+#git:framework/web/wrt-commons wrt-commons 0.2.102
 Name:       wrt-commons
 Summary:    Wrt common library
-Version:    0.2.101.1
+Version:    0.2.102
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
index 73e7ec53b185f496dd5e43878cf30eefefda735b..4348519ab5f4bfc41056950c9d72cd3d1f45a2c2 100644 (file)
@@ -40,6 +40,7 @@ SET(DPL_TESTS_CORE_SOURCES
     ${TESTS_DIR}/core/test_serialization.cpp
     ${TESTS_DIR}/core/test_scoped_array.cpp
     ${TESTS_DIR}/core/test_scoped_close.cpp
+    ${TESTS_DIR}/core/test_scoped_dir.cpp
     ${TESTS_DIR}/core/test_scoped_fclose.cpp
     ${TESTS_DIR}/core/test_scoped_free.cpp
     ${TESTS_DIR}/core/test_scoped_ptr.cpp
diff --git a/tests/core/test_scoped_dir.cpp b/tests/core/test_scoped_dir.cpp
new file mode 100644 (file)
index 0000000..8cf0c3c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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_scoped_dir.cpp
+ * @author      Iwanek Tomasz (t.iwanek@smasung.com)
+ * @version     1.0
+ * @brief       Scoped directory test
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/scoped_dir.h>
+
+#include <cstdio>
+#include <sstream>
+#include <cstdlib>
+
+#include <unistd.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: ScopedDir_Basic
+Description: tests if scoped directory is working
+Expected: directory created and removed
+*/
+RUNNER_TEST(ScopedDir_Basic)
+{
+    const char * path = "/tmp/wrttest123456";
+    if(access(path, F_OK) == 0)
+    {
+        RUNNER_ASSERT_MSG(!remove(path), "Cannot remove test directory");
+    }
+
+    {
+        DPL::ScopedDir dir(path, S_IRUSR | S_IWUSR);
+        std::ostringstream command;
+        command << "touch " << path << "/" << "file.txt";
+        (void)system(command.str().c_str());
+        RUNNER_ASSERT_MSG(access(path, R_OK) == 0, "Directory should be accessible");
+        RUNNER_ASSERT_MSG(access(path, W_OK) == 0, "Directory should be writable");
+    }
+    RUNNER_ASSERT_MSG(access(path, F_OK) != 0, "Directory should not exists");
+}
index 0fc686e6ca4b09553e7b4bf8dcc16f5549efd887..b7596efaaab2ee40989cb3eeb45cd3d557d62c10 100644 (file)
@@ -41,7 +41,7 @@ struct A
         ok_class = true;
     }
 };
-STATIC_BLOCK_CLASS( A, init );
+STATIC_BLOCK_CLASS( A, init )
 }
 
 /*
index dd2bd8a63340d53d4c386579395600179caead69..69a3e4acd88775dd765835bc617f2e5b9d001e58 100644 (file)
@@ -23,6 +23,7 @@
 #include <cmath>
 #include <cstring>
 #include <vector>
+#include <string>
 #include <dpl/test/test_runner.h>
 #include <dpl/string.h>
 #include <dpl/sstream.h>
@@ -416,3 +417,26 @@ RUNNER_TEST(String_CompareCaseInsensitive)
             true) == 0);
 }
 
+/*
+Name: String_Join
+Description: tests joining strings algorithm
+Expected: join should take place correctly
+*/
+RUNNER_TEST(String_Join)
+{
+    std::vector<std::string> strings;
+    RUNNER_ASSERT(DPL::Join(strings.begin(), strings.end(), "/") == "");
+    strings.push_back("one");
+    RUNNER_ASSERT(DPL::Join(strings.begin(), strings.end(), "/") == "one");
+    strings.push_back("two");
+    RUNNER_ASSERT(DPL::Join(strings.begin(), strings.end(), "/") == "one/two");
+    strings.push_back("three");
+    RUNNER_ASSERT(DPL::Join(strings.begin(), strings.end(), "/") == "one/two/three");
+    strings.push_back("four");
+    RUNNER_ASSERT(DPL::Join(strings.begin(), strings.end(), "/") == "one/two/three/four");
+    RUNNER_ASSERT(DPL::Join(++strings.begin(), --strings.end(), "/") == "two/three");
+
+    RUNNER_ASSERT(DPL::Join(strings.begin(), strings.end(), "+") == "one+two+three+four");
+    RUNNER_ASSERT(DPL::Join(strings.begin(), strings.end(), "delim") == "onedelimtwodelimthreedelimfour");
+}
+