[Release] wrt-plugins-common_0.3.110
authorsung-su.kim <sung-su.kim@samsung.com>
Wed, 14 Aug 2013 11:39:22 +0000 (20:39 +0900)
committersung-su.kim <sung-su.kim@samsung.com>
Wed, 14 Aug 2013 11:39:22 +0000 (20:39 +0900)
Change-Id: Ib308076d1c53c704dc02cb0414b4182343a4d7cf

24 files changed:
.gitignore
CMakeLists.txt
packaging/wrt-plugins-common.spec
pkgconfigs/wrt-plugins-widget-interface.pc.in [moved from pkgconfigs/wrt-plugins-widget-interface-dao.pc.in with 57% similarity]
src/Commons/CMakeLists.txt
src/Commons/FunctionDeclaration.h
src/Commons/WrtAccess/WrtAccess.cpp
src/Commons/WrtAccess/WrtAccess.h
src/CommonsJavaScript/Security/SecurityFunctionDeclaration.h
src/modules/API/LocalStorage/LocalStorageMgr.cpp
src/modules/packages/CMakeLists.txt
src/modules/packages/LocalStorage/CMakeLists.txt
src/modules/packages/WidgetInterface/CMakeLists.txt [moved from src/modules/packages/WidgetInterfaceDAO/CMakeLists.txt with 80% similarity]
src/modules/tizen/CMakeLists.txt
src/modules/tizen/WidgetInterface/CMakeLists.txt [new file with mode: 0644]
src/modules/tizen/WidgetInterface/WidgetInterface.cpp [new file with mode: 0644]
src/modules/tizen/WidgetInterface/WidgetInterface.h [moved from src/modules/tizen/WidgetInterfaceDAO/WidgetInterfaceDAO.h with 63% similarity]
src/modules/tizen/WidgetInterface/config.cmake [moved from src/modules/tizen/WidgetInterfaceDAO/config.cmake with 71% similarity]
src/modules/tizen/WidgetInterfaceDAO/CMakeLists.txt [deleted file]
src/modules/tizen/WidgetInterfaceDAO/WidgetInterfaceDAO.cpp [deleted file]
src/modules/tizen/WidgetInterfaceDAO/orm_generator_widget_interface.h [deleted file]
src/modules/tizen/WidgetInterfaceDAO/widget_interface_db [deleted file]
src/modules/tizen/WidgetInterfaceDAO/widget_interface_db_definitions [deleted file]
src/modules/tizen/WidgetInterfaceDAO/widget_interface_db_sql_generator.h [deleted file]

index 9fdb538..f32cf97 100644 (file)
@@ -35,8 +35,4 @@ pkgconfigs/*.pc
 *.swp
 cmake_build/*
 
-src/modules/slp2.0/WidgetInterfaceDAO/.widget_interface.db
-src/modules/slp2.0/WidgetInterfaceDAO/.widget_interface.db-journal
-src/modules/slp2.0/WidgetInterfaceDAO/widget_interface_db.sql
-
-/bin
\ No newline at end of file
+/bin
index 8777310..dd78270 100644 (file)
@@ -144,7 +144,7 @@ endmacro(configure_and_install_pkg)
 configure_and_install_pkg(wrt-plugins-commons-javascript.pc)
 configure_and_install_pkg(wrt-plugins-commons.pc)
 configure_and_install_pkg(wrt-plugins-filesystem.pc)
-configure_and_install_pkg(wrt-plugins-widget-interface-dao.pc)
+configure_and_install_pkg(wrt-plugins-widget-interface.pc)
 configure_and_install_pkg(wrt-plugins-widgetdb.pc)
 configure_and_install_pkg(wrt-plugins-plugin-manager.pc)
 configure_and_install_pkg(wrt-plugin-loading.pc)
index 726f354..19e1a14 100644 (file)
@@ -1,7 +1,7 @@
 #git:framework/web/wrt-plugins-common
 Name:       wrt-plugins-common
 Summary:    wrt-plugins common library
-Version:    0.3.108
+Version:    0.3.110
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
@@ -15,11 +15,11 @@ BuildRequires: pkgconfig(dpl-event-efl)
 BuildRequires: pkgconfig(ewebkit2)
 BuildRequires: pkgconfig(dpl-wrt-dao-ro)
 BuildRequires: pkgconfig(dpl-wrt-dao-rw)
-BuildRequires: pkgconfig(dpl-db-efl)
 BuildRequires: pkgconfig(libpcrecpp)
 BuildRequires: pkgconfig(icu-i18n)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(cert-svc-vcore)
+BuildRequires: pkgconfig(wrt-commons-widget-interface-dao)
 Requires:  ldconfig
 
 %description
@@ -76,7 +76,6 @@ touch /opt/share/widget/plugin-installation-required
 %{_libdir}/*.so
 %{_libdir}/*.so.*
 %{_libdir}/wrt-plugins/w3c-widget-interface/libwrt-plugins-w3c-widget-interface.so
-%attr(644,root,root) /usr/share/wrt-plugins-common/widget_interface_db.sql
 %attr(755,root,root) %{_bindir}/wrt-popup-ace-runtime
 %attr(755,root,root) %{_bindir}/wrt-popup-wrt-runtime
 %attr(755,root,root) %{_bindir}/wrt-plugins-installer
@@ -7,6 +7,6 @@ includedir=${prefix}/include/${project_name}
 Name: WebRuntime DeviceApis Widget Interface module
 Description: WebRuntime Widget Interface module
 Version: @CMAKE_PROJECT_VERSION@
-Requires: dpl-efl dpl-db-efl wrt-plugins-commons dpl-wrt-dao-ro wrt-plugins-localstorage
-Libs: -L${libdir} -lwrt-plugins-widget-interface-dao
-Cflags: -I${includedir}/WidgetInterfaceDAO
+Requires: dpl-efl wrt-plugins-commons dpl-wrt-dao-ro wrt-plugins-localstorage wrt-commons-widget-interface-dao
+Libs: -L${libdir} -lwrt-plugins-widget-interface
+Cflags: -I${includedir}/WidgetInterface
index 4d6e3b1..6b58193 100644 (file)
@@ -22,9 +22,9 @@ macro(install_wrtaccess_header_file HEADER_FILE)
         DESTINATION ${DESTINATION_HEADERS_NON_JS}/WrtAccess)
 endmacro()
 
-macro(install_widget_interface_dao_header_file HEADER_FILE)
+macro(install_widget_interface_header_file HEADER_FILE)
     INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER_FILE}
-        DESTINATION ${DESTINATION_HEADERS_NON_JS}/WidgetInterfaceDAO)
+        DESTINATION ${DESTINATION_HEADERS_NON_JS}/WidgetInterface)
 endmacro()
 
 include_config_file(WrtAccess)
index 9075268..d603c49 100644 (file)
@@ -108,6 +108,7 @@ enum class AceSecurityStatus
 {
     AccessGranted,
     AccessDenied,
+    PrivacyDenied,
     InternalError
 };
 
@@ -146,8 +147,17 @@ AceSecurityStatus aceCheckAccess(
     ArgumentsVerifier argsVerify;
     argsVerify(aceFunction, args ...);
 
-    if (!(WrtAccessSingleton::Instance().checkAccessControl(aceFunction))) {
-            return AceSecurityStatus::AccessDenied;
+    WrtAccess::CheckAccessReturnType ret =
+        WrtAccessSingleton::Instance().checkAccessControl(aceFunction);
+
+    if (ret == WrtAccess::CHECK_ACCESS_PRIVILEGE_DENIED) {
+        return AceSecurityStatus::AccessDenied;
+    }
+    else if (ret == WrtAccess::CHECK_ACCESS_PRIVACY_DENIED) {
+        return AceSecurityStatus::PrivacyDenied;
+    }
+    else if (ret == WrtAccess::CHECK_ACCESS_INTERNAL_ERROR) {
+        return AceSecurityStatus::InternalError;
     }
 
     return AceSecurityStatus::AccessGranted;
index 0e9f50a..128dbf5 100644 (file)
@@ -172,7 +172,7 @@ int WrtAccess::getWidgetId() const
     return m_widgetId;
 }
 
-bool WrtAccess::checkAccessControl(const AceFunction& aceFunction) const
+WrtAccess::CheckAccessReturnType WrtAccess::checkAccessControl(const AceFunction& aceFunction) const
 {
     Assert(
         m_pluginOwners && "WrtAccessSingleton needs to be initialized with"
@@ -249,9 +249,9 @@ bool WrtAccess::checkAccessControl(const AceFunction& aceFunction) const
         }
     }
 
-    ace_bool_t aceCheckResult = ACE_FALSE;
+    ace_check_result_t aceCheckResult = ACE_PRIVILEGE_DENIED;
     DPL::Log::LogSystemSingleton::Instance().SetTag("SECURITY_DAEMON");
-    ace_return_t ret = ace_check_access(&aceRequest, &aceCheckResult);
+    ace_return_t ret = ace_check_access_ex(&aceRequest, &aceCheckResult);
     DPL::Log::LogSystemSingleton::Instance().SetTag("WRT_PLUGINS");
     for (i = 0; i < deviceCount; ++i) {
         delete[] aceRequest.dev_cap_list.items[i].param_list.items;
@@ -260,9 +260,20 @@ bool WrtAccess::checkAccessControl(const AceFunction& aceFunction) const
 
     if (ACE_OK != ret) {
         _E("Error in ace check: %d", static_cast<int>(ret));
-        return false;
+        return CHECK_ACCESS_INTERNAL_ERROR;
     }
-    return ACE_TRUE == aceCheckResult;
+
+    if (aceCheckResult == ACE_ACCESS_GRANTED) {
+        return CHECK_ACCESS_GRANTED;
+    }
+    else if (aceCheckResult == ACE_PRIVILEGE_DENIED) {
+        return CHECK_ACCESS_PRIVILEGE_DENIED;
+    }
+    else if (aceCheckResult == ACE_PRIVACY_DENIED) {
+        return CHECK_ACCESS_PRIVACY_DENIED;
+    }
+
+    return CHECK_ACCESS_INTERNAL_ERROR;
 }
 }
 } // WrtDeviceApisCommon
index 7467215..c274534 100644 (file)
@@ -31,11 +31,19 @@ namespace WrtDeviceApis {
 namespace Commons {
 class WrtAccess
 {
+    enum CheckAccessReturnType
+    {
+        CHECK_ACCESS_GRANTED,
+        CHECK_ACCESS_PRIVILEGE_DENIED,
+        CHECK_ACCESS_PRIVACY_DENIED,
+        CHECK_ACCESS_INTERNAL_ERROR
+    };
+
   public:
     void initialize(int widgetId);
     void deinitialize(int widgetId);
     int getWidgetId() const;
-    bool checkAccessControl(const AceFunction &aceFunction) const;
+    CheckAccessReturnType checkAccessControl(const AceFunction &aceFunction) const;
 
   private:
 
index dcdd452..8ad1987 100644 (file)
@@ -30,6 +30,7 @@ enum class AceSecurityStatus
 {
     AccessGranted,
     AccessDenied,
+    PrivacyDenied,
     InternalError
 };
 
@@ -65,15 +66,19 @@ AceSecurityStatus aceCheckAccess2(
     ArgumentsVerifier argsVerify;
     argsVerify(aceFunction, args ...);
 
-    Try {
-        if (!(WrtAccessSingleton::Instance().checkAccessControl(aceFunction)))
-        {
-            LogDebug("Function is not allowed to run");
-            return AceSecurityStatus::AccessDenied;
-        }
+    WrtAccess::CheckAccessReturnType ret =
+        WrtAccessSingleton::Instance().checkAccessControl(aceFunction);
+
+    if (ret == WrtAccess::CHECK_ACCESS_PRIVILEGE_DENIED) {
+        LogError("Function is not allowed to run - AccessDenied");
+        return AceSecurityStatus::AccessDenied;
+    }
+    else if (ret == WrtAccess::CHECK_ACCESS_PRIVACY_DENIED) {
+        LogError("Function is not allowed to run - PrivacyDenied");
+        return AceSecurityStatus::PrivacyDenied;
     }
-    Catch(WrtDeviceApis::Commons::OutOfRangeException) {
-        LogError("WrtAccess doesn't exist.");
+    else if (ret == WrtAccess::CHECK_ACCESS_INTERNAL_ERROR) {
+        LogError("InternalError");
         return AceSecurityStatus::InternalError;
     }
 
index 7cb7492..04e9cc8 100644 (file)
  * @brief
  */
 #include "LocalStorageMgr.h"
-#include <WidgetInterfaceDAO/WidgetInterfaceDAO.h>
+#include <WidgetInterface/WidgetInterface.h>
 
 namespace WrtDeviceApis {
 namespace LocalStorage {
 namespace Api {
 ILocalStoragePtr getLocalStorage(int widgetId)
 {
-    return ILocalStoragePtr(new WrtDeviceApis::WidgetInterfaceDAO(widgetId));
+    return ILocalStoragePtr(new WrtDeviceApis::WidgetInterfaceObject(widgetId));
 }
 } // Api
 } // LocalStorage
index beadcd3..ed3e799 100644 (file)
@@ -16,7 +16,7 @@
 set(TARGET_MODULE_FILESYSTEM "wrt-plugins-filesystem")
 set(TARGET_MODULE_WIDGET "wrt-plugins-widget")
 set(TARGET_MODULE_LOCALSTORAGE "wrt-plugins-localstorage")
-set(TARGET_MODULE_WIDGET_INTERFACE_DAO "wrt-plugins-widget-interface-dao")
+set(TARGET_MODULE_WIDGET_INTERFACE "wrt-plugins-widget-interface")
 set(TARGET_MODULE_STORAGEEVENT "wrt-plugins-storageevent")
 set(TARGET_MODULE_TIZEN_SERVICE_EVENT "wrt-plugins-tizen-service-event")
 set(TARGET_MODULE_SOFTKEYBOARD_CHANGE_EVENT "wrt-plugins-softkeyboardchange-event")
@@ -26,7 +26,7 @@ set(TARGET_MODULE_PLUGIN_MANAGER "wrt-plugins-plugin-manager")
 add_subdirectory(Filesystem)
 add_subdirectory(Widget)
 add_subdirectory(LocalStorage)
-add_subdirectory(WidgetInterfaceDAO)
+add_subdirectory(WidgetInterface)
 add_subdirectory(WidgetDB)
 add_subdirectory(PluginManager)
 add_subdirectory(StorageEvent)
index 2b0a894..90d648a 100644 (file)
@@ -23,6 +23,6 @@ add_library(${TARGET_NAME} STATIC ${SRCS})
 target_link_libraries(${TARGET_NAME}
    ${LIBS_COMMONS}
    ${TARGET_COMMONS}
-   ${TARGET_MODULE_WIDGET_INTERFACE_DAO}
+   ${TARGET_MODULE_WIDGET_INTERFACE}
 )
 
 
 macro(install_header_file HEADER_FILE)
     INSTALL(FILES ${API_WIDGET_INTERFACE_PATH}/${HEADER_FILE}
-        DESTINATION ${DESTINATION_HEADER_PREFIX}/WidgetInterfaceDAO)
+        DESTINATION ${DESTINATION_HEADER_PREFIX}/WidgetInterface)
 endmacro()
 
 pkg_search_module(dpl-wrt-dao-ro REQUIRED dpl-wrt-dao-ro)
-pkg_search_module(dpl-db REQUIRED dpl-db-efl)
+pkg_search_module(wrt-commons-widget-interface-dao REQUIRED wrt-commons-widget-interface-dao)
 
 include_directories(
     ${WIDGET_INTERFACE_INCLUDE_DIRS}
     ${dpl-wrt-dao-ro_INCLUDE_DIRS}
-    ${dpl-db_INCLUDE_DIRS})
+    ${wrt-commons-widget-interface-dao_INCLUDE_DIRS})
 
-set(TARGET_NAME ${TARGET_MODULE_WIDGET_INTERFACE_DAO})
+set(TARGET_NAME ${TARGET_MODULE_WIDGET_INTERFACE})
 
 set(SRCS
-    ${SRCS_WIDGET_INTERFACE_DAO}
+    ${SRCS_WIDGET_INTERFACE}
 )
 
 add_library(${TARGET_NAME} SHARED ${SRCS})
 
 target_link_libraries(${TARGET_NAME}
    ${LIBS_COMMONS}
-   ${dpl-db_LIBRARIES}
    ${dpl-wrt-dao-ro_LIBRARIES}
+   ${wrt-commons-widget-interface-dao_LIBRARIES}
 )
 set_target_properties(${TARGET_NAME} PROPERTIES 
  SOVERSION ${CMAKE_PROJECT_API_VERSION}
@@ -47,4 +47,4 @@ set_target_properties(${TARGET_NAME} PROPERTIES
 INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION
     ${DESTINATION_LIB_PREFIX})
 
-install_header_file(WidgetInterfaceDAO.h)
+install_header_file(WidgetInterface.h)
index 85b3a95..3cfc293 100644 (file)
@@ -25,7 +25,7 @@
 include_config_file(Filesystem)
 include_config_file(Widget)
 include_config_file(LocalStorage)
-include_config_file(WidgetInterfaceDAO)
-add_subdirectory(WidgetInterfaceDAO)
+include_config_file(WidgetInterface)
+add_subdirectory(WidgetInterface)
 include_config_file(WidgetDB)
 include_config_file(PluginManager)
diff --git a/src/modules/tizen/WidgetInterface/CMakeLists.txt b/src/modules/tizen/WidgetInterface/CMakeLists.txt
new file mode 100644 (file)
index 0000000..883f3d1
--- /dev/null
@@ -0,0 +1,6 @@
+
+get_current_path()
+
+pkg_search_module(wrt-commons-widget-interface-dao REQUIRED wrt-commons-widget-interface-dao)
+
+include_directories(${CURRENT_PATH})
diff --git a/src/modules/tizen/WidgetInterface/WidgetInterface.cpp b/src/modules/tizen/WidgetInterface/WidgetInterface.cpp
new file mode 100644 (file)
index 0000000..cfd9c8c
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * 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.
+ */
+/*
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#include "WidgetInterface.h"
+#include <string>
+#include <dpl/exception.h>
+#include <dpl/log/log.h>
+#include <dpl/optional.h>
+#include <dpl/string.h>
+#include <wrt-commons/widget-interface-dao/widget_interface_dao.h>
+#include <Commons/Exception.h>
+
+namespace WrtDeviceApis {
+using namespace WidgetInterfaceDB;
+
+WidgetInterfaceObject::WidgetInterfaceObject(int widgetHandle)
+{
+    Try
+    {
+        m_dao.reset(new WidgetInterfaceDAO(widgetHandle));
+    }
+    Catch(WidgetInterfaceDAO::Exception::DatabaseError)
+    {
+        ReThrow(Commons::PlatformException);
+    }
+}
+
+WidgetInterfaceObject::~WidgetInterfaceObject()
+{
+    m_dao.reset();
+}
+
+void WidgetInterfaceObject::setItem(const std::string& key,
+                                    const std::string& value,
+                                    bool readOnly)
+{
+    Try
+    {
+        m_dao->setItem(key, value, readOnly);
+    }
+    Catch(WidgetInterfaceDAO::Exception::DatabaseError)
+    {
+        ReThrow(Commons::PlatformException);
+    }
+    Catch(WidgetInterfaceDAO::Exception::LocalStorageValueNoModifableException)
+    {
+        LogError("Cannot delete item. Item is readonly");
+        ReThrow(Commons::LocalStorageValueNoModifableException);
+    }
+}
+
+void WidgetInterfaceObject::removeItem(const std::string& key)
+{
+    Try
+    {
+        m_dao->removeItem(key);
+    }
+    Catch(WidgetInterfaceDAO::Exception::DatabaseError)
+    {
+        ReThrow(Commons::PlatformException);
+    }
+    Catch(WidgetInterfaceDAO::Exception::LocalStorageValueNoModifableException)
+    {
+        LogError("Cannot delete item. Item is readonly");
+        ReThrow(Commons::LocalStorageValueNoModifableException);
+    }
+}
+
+DPL::Optional<std::string> WidgetInterfaceObject::getValue(
+    const std::string& key) const
+{
+    Try
+    {
+        return m_dao->getValue(key);
+    }
+    Catch(WidgetInterfaceDAO::Exception::DatabaseError)
+    {
+        ReThrow(Commons::PlatformException);
+    }
+}
+
+void WidgetInterfaceObject::clear(bool removeReadOnly)
+{
+    Try
+    {
+        m_dao->clear(removeReadOnly);
+    }
+    Catch(WidgetInterfaceDAO::Exception::DatabaseError)
+    {
+        ReThrow(Commons::PlatformException);
+    }
+}
+
+size_t WidgetInterfaceObject::getStorageSize() const
+{
+    Try
+    {
+        return m_dao->getStorageSize();
+    }
+    Catch(WidgetInterfaceDAO::Exception::DatabaseError)
+    {
+        ReThrow(Commons::PlatformException);
+    }
+}
+
+std::string WidgetInterfaceObject::getKeyByIndex(size_t index) const
+{
+    Try
+    {
+        return m_dao->getKeyByIndex(index);
+    }
+    Catch(WidgetInterfaceDAO::Exception::DatabaseError)
+    {
+        ReThrow(Commons::PlatformException);
+    }
+    Catch(WidgetInterfaceDAO::Exception::InvalidArgumentException)
+    {
+        ReThrow(Commons::InvalidArgumentException);
+    }
+}
+}
  * @brief
  */
 
-#ifndef WRTDEVICEAPIS_COMMONS_WIDGET_INTERFACE_DAO_H_
-#define WRTDEVICEAPIS_COMMONS_WIDGET_INTERFACE_DAO_H_
+#ifndef WRTDEVICEAPIS_COMMONS_WIDGET_INTERFACE_H_
+#define WRTDEVICEAPIS_COMMONS_WIDGET_INTERFACE_H_
 
 #include <string>
-#include <dpl/db/thread_database_support.h>
-#include <dpl/db/orm_interface.h>
+#include <dpl/optional.h>
+#include <wrt-commons/widget-interface-dao/widget_interface_dao.h>
 #include <LocalStorage/ILocalStorage.h>
 
 namespace WrtDeviceApis {
-class WidgetInterfaceDAO :
+class WidgetInterfaceObject :
     public LocalStorage::Api::ILocalStorage
 {
   public:
-    WidgetInterfaceDAO(int widgetHandle);
-    virtual ~WidgetInterfaceDAO();
+    WidgetInterfaceObject(int widgetHandle);
+    virtual ~WidgetInterfaceObject();
 
     void setItem(const std::string& key,
                  const std::string& value,
-                 bool readOnly,
-                 bool fromConfigXml);
-    void setItem(const std::string& key,
-                 const std::string& value,
                  bool readOnly);
     void removeItem(const std::string& key);
     DPL::Optional<std::string> getValue(const std::string& key) const;
@@ -48,15 +44,9 @@ class WidgetInterfaceDAO :
     size_t getStorageSize() const;
     std::string getKeyByIndex(size_t index) const;
 
-  protected:
-    int m_widgetHandle;
-    mutable DPL::DB::ThreadDatabaseSupport m_databaseInterface;
-
   private:
-    bool checkDatabase();
-    bool copyPropertiesFromWrtDatabase();
-    static std::string databaseFileName(int widgetHandle);
+    WidgetInterfaceDB::WidgetInterfaceDAOPtr m_dao;
 };
 }
 
-#endif //WRTDEVICEAPIS_COMMONS_WIDGET_INTERFACE_DAO_H_
\ No newline at end of file
+#endif //WRTDEVICEAPIS_COMMONS_WIDGET_INTERFACE_H_
@@ -11,7 +11,7 @@ SET(API_WIDGET_INTERFACE_PATH
     PARENT_SCOPE
 )
 
-set(SRCS_WIDGET_INTERFACE_DAO
-    ${CURRENT_PATH}/WidgetInterfaceDAO.cpp
+set(SRCS_WIDGET_INTERFACE
+    ${CURRENT_PATH}/WidgetInterface.cpp
     PARENT_SCOPE
 )
diff --git a/src/modules/tizen/WidgetInterfaceDAO/CMakeLists.txt b/src/modules/tizen/WidgetInterfaceDAO/CMakeLists.txt
deleted file mode 100644 (file)
index 60886cf..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-
-get_current_path()
-
-pkg_search_module(dpl-db REQUIRED dpl-db-efl)
-
-include_directories(${CURRENT_PATH})
-
-STRING(REPLACE ";" ":" SQL_GENERATOR_INCLUDE_DIRS "${dpl-db_INCLUDE_DIRS}")
-
-ADD_CUSTOM_COMMAND( OUTPUT ${CURRENT_PATH}/widget_interface_db.sql
-  COMMAND rm -f ${CURRENT_PATH}/.widget_interface.db
-  COMMAND rm -f ${CURRENT_PATH}/widget_interface_db.sql
-  COMMAND CPATH=${SQL_GENERATOR_INCLUDE_DIRS} gcc -Wall -E ${CURRENT_PATH}/widget_interface_db_sql_generator.h | grep --invert-match "^#" > ${CURRENT_PATH}/widget_interface_db.sql
-  COMMAND sqlite3 ${CURRENT_PATH}/.widget_interface.db ".read ${CURRENT_PATH}/widget_interface_db.sql" || rm -f ${CURRENT_PATH}/.widget_interface.db
-  DEPENDS ${CURRENT_PATH}/widget_interface_db_sql_generator.h ${CURRENT_PATH}/widget_interface_db
-)
-
-ADD_CUSTOM_TARGET(Sqlite3Db ALL DEPENDS ${CURRENT_PATH}/widget_interface_db.sql)
-
-INSTALL(FILES ${CURRENT_PATH}/widget_interface_db.sql
-    DESTINATION share/wrt-plugins-common/
-)
diff --git a/src/modules/tizen/WidgetInterfaceDAO/WidgetInterfaceDAO.cpp b/src/modules/tizen/WidgetInterfaceDAO/WidgetInterfaceDAO.cpp
deleted file mode 100644 (file)
index 35504bf..0000000
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * 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.
- */
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#include "WidgetInterfaceDAO.h"
-#include <string>
-#include <sstream>
-#include <fstream>
-#include <sys/stat.h>
-#include <dpl/db/sql_connection.h>
-#include <dpl/log/log.h>
-#include <dpl/foreach.h>
-#include <dpl/string.h>
-#include <Commons/Exception.h>
-#include <dpl/wrt-dao-ro/property_dao_read_only.h>
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-#include <dpl/wrt-dao-ro/WrtDatabase.h>
-#include <dpl/wrt-dao-ro/widget_config.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include "orm_generator_widget_interface.h"
-namespace {
-DPL::DB::SqlConnection::Flag::Type DATABASE_FLAGS =
-    DPL::DB::SqlConnection::Flag::UseLucene;
-DPL::DB::SqlConnection::Flag::Option DATABASE_OPTIONS =
-    DPL::DB::SqlConnection::Flag::RW;
-const char *KEY_WIDGET_ARG = "widget_arg";
-}
-
-namespace WrtDeviceApis {
-WidgetInterfaceDAO::WidgetInterfaceDAO(int widgetHandle) :
-    m_widgetHandle(widgetHandle),
-    m_databaseInterface(databaseFileName(widgetHandle), DATABASE_FLAGS)
-{
-    if (!checkDatabase()) {
-        LogError("There is a problem with database");
-    }
-    m_databaseInterface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
-}
-
-WidgetInterfaceDAO::~WidgetInterfaceDAO()
-{
-    m_databaseInterface.DetachFromThread();
-}
-
-bool WidgetInterfaceDAO::checkDatabase()
-{
-    using namespace WrtDB::GlobalConfig;
-    std::string databaseFile = databaseFileName(m_widgetHandle);
-    struct stat buffer;
-    if (stat(databaseFile.c_str(), &buffer) != 0) {
-        //Create fresh database
-
-        LogDebug("Creating database " << databaseFile);
-
-        std::fstream file;
-        file.open(GetWrtWidgetInterfaceDatabaseFilePath(), std::ios_base::in);
-        if (!file) {
-            LogError("Cannot create database. SQL file is missing.");
-            return false;
-        }
-
-        std::stringstream buffer;
-        buffer << file.rdbuf();
-
-        file.close();
-
-        Try
-        {
-            DPL::DB::SqlConnection con(databaseFile,
-                                       DATABASE_FLAGS, DATABASE_OPTIONS);
-            con.ExecCommand(buffer.str().c_str());
-        }
-        Catch(DPL::DB::SqlConnection::Exception::Base)
-        {
-            LogError("Cannot create database");
-            return false;
-        }
-        copyPropertiesFromWrtDatabase();
-    }
-    return true;
-}
-
-bool WidgetInterfaceDAO::copyPropertiesFromWrtDatabase()
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::widget_interface;
-
-    bool result = true;
-    WrtDB::WrtDatabase::attachToThreadRO();
-    m_databaseInterface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
-
-    Try
-    {
-        WrtDB::PropertyDAOReadOnly::WidgetPreferenceList existing =
-            WrtDB::PropertyDAOReadOnly::GetPropertyList(m_widgetHandle);
-
-        Try
-        {
-            //save all properties read from config.xml
-            FOREACH(prop, existing) {
-                std::string key = DPL::ToUTF8String(prop->key_name);
-                if (key != KEY_WIDGET_ARG) {
-                    std::string value;
-                    if (!prop->key_value.IsNull()) {
-                        value = DPL::ToUTF8String(*(prop->key_value));
-                    }
-                    bool readonly =
-                        !prop->readonly.IsNull() && (*prop->readonly);
-                    setItem(key, value, readonly, true);
-                }
-            }
-        }
-        Catch(Commons::Exception)
-        {
-            LogError("Cannot copy properties read from config.xml");
-            result = false;
-        }
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base)
-    {
-        LogError("Cannot copy properties read from config.xml");
-        result = false;
-    }
-    WrtDB::WrtDatabase::detachFromThread();
-    m_databaseInterface.DetachFromThread();
-    return result;
-}
-
-void WidgetInterfaceDAO::setItem(const std::string& key,
-                                 const std::string& value,
-                                 bool readOnly)
-{
-    setItem(key, value, readOnly, false);
-}
-
-void WidgetInterfaceDAO::setItem(const std::string& key,
-                                 const std::string& value,
-                                 bool readOnly,
-                                 bool fromConfigXml)
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::widget_interface;
-
-    Try
-    {
-        ScopedTransaction tran(&m_databaseInterface);
-        //check if key exists
-        Properties::Select select(&m_databaseInterface);
-        select.Where(
-            Equals<Properties::key>(DPL::FromUTF8String(key)));
-        std::list<Properties::Row> rows = select.GetRowList();
-
-        if (rows.empty()) {
-            Properties::Insert insert(&m_databaseInterface);
-            Properties::Row row;
-            row.Set_key(DPL::FromUTF8String(key));
-            row.Set_value(DPL::FromUTF8String(value));
-            row.Set_readonly(readOnly ? 1 : 0);
-            row.Set_configxml(fromConfigXml ? 1 : 0);
-            insert.Values(row);
-            insert.Execute();
-        } else {
-            Assert(rows.size() == 1);
-            Properties::Row row = rows.front();
-            if (row.Get_readonly() != 0) {
-                Throw(Commons::LocalStorageValueNoModifableException);
-            }
-            row.Set_value(DPL::FromUTF8String(value));
-            row.Set_readonly(readOnly ? 1 : 0);
-            Properties::Update update(&m_databaseInterface);
-            update.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
-            update.Values(row);
-            update.Execute();
-        }
-        tran.Commit();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base)
-    {
-        LogError("Cannot set item " << key << " with value " << value);
-        ReThrow(Commons::PlatformException);
-    }
-}
-
-void WidgetInterfaceDAO::removeItem(const std::string& key)
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::widget_interface;
-
-    Try
-    {
-        Properties::Select select(&m_databaseInterface);
-        select.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
-        bool readonly = select.GetSingleValue<Properties::readonly>();
-        if (readonly) {
-            ThrowMsg(Commons::LocalStorageValueNoModifableException,
-                     "Cannot delete item. Item is readonly");
-        }
-        Properties::Delete deleteItem(&m_databaseInterface);
-        deleteItem.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
-        deleteItem.Execute();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base)
-    {
-        LogError("Cannot delete item " << key);
-        ReThrow(Commons::PlatformException);
-    }
-}
-
-DPL::Optional<std::string> WidgetInterfaceDAO::getValue(
-    const std::string& key) const
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::widget_interface;
-
-    Try
-    {
-        Properties::Select select(&m_databaseInterface);
-        select.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
-        std::list<DPL::String> value = select.GetValueList<Properties::value>();
-        if (value.empty()) {
-            return DPL::Optional<std::string>();
-        }
-        return DPL::Optional<std::string>(DPL::ToUTF8String(value.front()));
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base)
-    {
-        LogError("Not found item " << key);
-        ReThrow(Commons::PlatformException);
-    }
-}
-
-void WidgetInterfaceDAO::clear(bool removeReadOnly)
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::widget_interface;
-    Try
-    {
-        Properties::Delete deleteItem(&m_databaseInterface);
-        if (!removeReadOnly) {
-            deleteItem.Where(Equals<Properties::readonly>(0));
-        }
-        deleteItem.Execute();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base)
-    {
-        LogError("Cannot delete all items");
-        ReThrow(Commons::PlatformException);
-    }
-}
-
-size_t WidgetInterfaceDAO::getStorageSize() const
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::widget_interface;
-
-    Try
-    {
-        Properties::Select select(&m_databaseInterface);
-        std::list<DPL::String> list =
-            select.GetValueList<Properties::key>();
-        return list.size();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base)
-    {
-        LogError("Cannot get item count");
-        ReThrow(Commons::PlatformException);
-    }
-    return 0;
-}
-
-std::string WidgetInterfaceDAO::getKeyByIndex(size_t index) const
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::widget_interface;
-
-    Try
-    {
-        Properties::Select select(&m_databaseInterface);
-        select.OrderBy("key");
-        std::list<DPL::String> list =
-            select.GetValueList<Properties::key>();
-        if (index >= list.size()) {
-            Throw(Commons::InvalidArgumentException);
-        }
-        for (size_t i = 0; i < index; ++i) {
-            list.pop_front();
-        }
-        return DPL::ToUTF8String(list.front());
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base)
-    {
-        LogError("Cannot get item count");
-        ReThrow(Commons::PlatformException);
-    }
-}
-
-std::string WidgetInterfaceDAO::databaseFileName(int widgetHandle)
-{
-    using namespace DPL::DB::ORM;
-    using namespace WrtDB::WidgetConfig;
-    using namespace WrtDB::GlobalConfig;
-
-    WrtDB::WrtDatabase::attachToThreadRO();
-
-    std::stringstream filename;
-    Try
-    {
-        WrtDB::WidgetDAOReadOnly widgetDAO(widgetHandle);
-        WrtDB::TizenPkgId pkgid = widgetDAO.getTizenPkgId();
-
-        filename << GetWidgetPersistentStoragePath(pkgid)
-                 << "/"
-                 << GetWidgetInterfaceDatabaseFile();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base)
-    {
-        LogError("Cannot get item count");
-        ReThrow(Commons::PlatformException);
-    }
-    WrtDB::WrtDatabase::detachFromThread();
-    return filename.str();
-}
-}
diff --git a/src/modules/tizen/WidgetInterfaceDAO/orm_generator_widget_interface.h b/src/modules/tizen/WidgetInterfaceDAO/orm_generator_widget_interface.h
deleted file mode 100644 (file)
index 87a3e05..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef ORM_GENERATOR_WIDGET_INTERFACE_H_
-#define ORM_GENERATOR_WIDGET_INTERFACE_H_
-
-#define ORM_GENERATOR_DATABASE_NAME widget_interface_db_definitions
-#include <dpl/db/orm_generator.h>
-#undef ORM_GENERATOR_DATABASE_NAME
-
-#endif
diff --git a/src/modules/tizen/WidgetInterfaceDAO/widget_interface_db b/src/modules/tizen/WidgetInterfaceDAO/widget_interface_db
deleted file mode 100644 (file)
index d33ec48..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-SQL(
-    PRAGMA foreign_keys = ON;
-    BEGIN TRANSACTION;
-)
-
-CREATE_TABLE(Properties)
-    COLUMN_NOT_NULL(key,      TEXT,)
-    COLUMN_NOT_NULL(value,    TEXT,)
-    COLUMN_NOT_NULL(readonly, INTEGER, check(readonly between 0 and 1))
-    COLUMN_NOT_NULL(configxml, INTEGER, check(readonly between 0 and 1) DEFAULT 0)
-
-    TABLE_CONSTRAINTS(unique(key))
-CREATE_TABLE_END()
-
-SQL(
-    COMMIT;
-)
diff --git a/src/modules/tizen/WidgetInterfaceDAO/widget_interface_db_definitions b/src/modules/tizen/WidgetInterfaceDAO/widget_interface_db_definitions
deleted file mode 100644 (file)
index 85f627d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-DATABASE_START(widget_interface)
-
-#include "widget_interface_db"
-
-DATABASE_END()
diff --git a/src/modules/tizen/WidgetInterfaceDAO/widget_interface_db_sql_generator.h b/src/modules/tizen/WidgetInterfaceDAO/widget_interface_db_sql_generator.h
deleted file mode 100644 (file)
index b4ce0b6..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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        wrt_db_sql_generator.h
- * @author      Bartosz Janiak (b.janiak@samsung.com)
- * @version     1.0
- * @brief       Macro definitions for generating the SQL input file from
- * database definition.
- */
-
-//Do not include this file directly! It is used only for SQL code generation.
-
-#include <dpl/db/orm_macros.h>
-
-#include "widget_interface_db_definitions"