*.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
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)
#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
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
%{_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
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
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)
{
AccessGranted,
AccessDenied,
+ PrivacyDenied,
InternalError
};
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;
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"
}
}
- 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;
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
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:
{
AccessGranted,
AccessDenied,
+ PrivacyDenied,
InternalError
};
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;
}
* @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
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")
add_subdirectory(Filesystem)
add_subdirectory(Widget)
add_subdirectory(LocalStorage)
-add_subdirectory(WidgetInterfaceDAO)
+add_subdirectory(WidgetInterface)
add_subdirectory(WidgetDB)
add_subdirectory(PluginManager)
add_subdirectory(StorageEvent)
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}
INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION
${DESTINATION_LIB_PREFIX})
-install_header_file(WidgetInterfaceDAO.h)
+install_header_file(WidgetInterface.h)
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)
--- /dev/null
+
+get_current_path()
+
+pkg_search_module(wrt-commons-widget-interface-dao REQUIRED wrt-commons-widget-interface-dao)
+
+include_directories(${CURRENT_PATH})
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @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;
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_
PARENT_SCOPE
)
-set(SRCS_WIDGET_INTERFACE_DAO
- ${CURRENT_PATH}/WidgetInterfaceDAO.cpp
+set(SRCS_WIDGET_INTERFACE
+ ${CURRENT_PATH}/WidgetInterface.cpp
PARENT_SCOPE
)
+++ /dev/null
-
-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/
-)
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @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();
-}
-}
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#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
+++ /dev/null
-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;
-)
+++ /dev/null
-DATABASE_START(widget_interface)
-
-#include "widget_interface_db"
-
-DATABASE_END()
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file 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"