From: Krzysztof Jackiewicz Date: Fri, 30 Nov 2012 13:34:17 +0000 (+0100) Subject: CustomHandlers DAO libraries stubs added X-Git-Tag: submit/trunk/20121210.022115~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e408b634d9de057c6e46bf66b2c8a3e682a9a87d;p=platform%2Fframework%2Fweb%2Fwrt-commons.git CustomHandlers DAO libraries stubs added [Issue#] N/A [Feature] Custom handlers implementation [Problem] N/A [Cause] Custom handlers information has to be stored in the database [Solution] Stub for custom handlers DAO added [Verification] 1.Succesfull compilation of wrt-commons and wrt-extra. 2.Run wrt-tests-dao --output=text --regexp=custom_handler_dao_basic. It should pass. Change-Id: Iaf87fda801d60221d573f747a506664b987589bb --- diff --git a/.gitignore b/.gitignore index 9488fa3..fb11196 100755 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ documentation.list modules/auto_save_dao/database_checksum_autosave.h modules/widget_dao/database_checksum.h modules/security_origin_dao/database_checksum_security_origin.h +modules/custom_handler_dao/database_checksum_custom_handler.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a2b37d..06da368 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,6 +185,8 @@ SET(TARGET_WRT_DAO_RO_LIB "dpl-wrt-dao-ro") 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_CUSTOM_HANDLER_DAO_RW_LIB "wrt-commons-custom-handler-dao-rw") +SET(TARGET_CUSTOM_HANDLER_DAO_RO_LIB "wrt-commons-custom-handler-dao-ro") SET(TARGET_SECURITY_ORIGIN_DAO_LIB "wrt-commons-security-origin-dao") SET(TARGET_DPL_UTILS_EFL "lib${PROJECT_NAME}-utils-efl") SET(TARGET_DPL_ENCRYPTION "lib${PROJECT_NAME}-encryption") diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 2e40a76..e11b0e9 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -29,6 +29,7 @@ ADD_SUBDIRECTORY(test) ADD_SUBDIRECTORY(widget_dao) ADD_SUBDIRECTORY(auto_save_dao) ADD_SUBDIRECTORY(security_origin_dao) +ADD_SUBDIRECTORY(custom_handler_dao) ADD_SUBDIRECTORY(popup) ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(support) diff --git a/build/custom_handler_dao/CMakeLists.txt b/build/custom_handler_dao/CMakeLists.txt new file mode 100644 index 0000000..26e701c --- /dev/null +++ b/build/custom_handler_dao/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright (c) 2012 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 Krzysztof Jackiewicz (k.jackiewicz@samsung.com) +# @brief +# + +configure_and_install_pkg(wrt-commons-custom-handler-dao-ro.pc) +configure_and_install_pkg(wrt-commons-custom-handler-dao-rw.pc) diff --git a/build/custom_handler_dao/wrt-commons-custom-handler-dao-ro.pc.in b/build/custom_handler_dao/wrt-commons-custom-handler-dao-ro.pc.in new file mode 100644 index 0000000..7cda187 --- /dev/null +++ b/build/custom_handler_dao/wrt-commons-custom-handler-dao-ro.pc.in @@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=${prefix} + +libdir=${prefix}/lib +includedir=${prefix}/include +Name: wrt-commons-custom-handler-dao-ro +Description: wrt-commons-custom-handler-dao-ro + +Version: @VERSION@ +Requires: dpl-efl +Libs: -lwrt-commons-custom-handler-dao-ro -L${libdir} +Cflags: -I${includedir}/dpl-efl diff --git a/build/custom_handler_dao/wrt-commons-custom-handler-dao-rw.pc.in b/build/custom_handler_dao/wrt-commons-custom-handler-dao-rw.pc.in new file mode 100644 index 0000000..4cd2737 --- /dev/null +++ b/build/custom_handler_dao/wrt-commons-custom-handler-dao-rw.pc.in @@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=${prefix} + +libdir=${prefix}/lib +includedir=${prefix}/include +Name: wrt-commons-custom-handler-dao-rw +Description: wrt-commons-custom-handler-dao-rw + +Version: @VERSION@ +Requires: dpl-efl wrt-commons-custom-handler-dao-ro +Libs: -lwrt-commons-custom-handler-dao-rw -lwrt-commons-custom-handler-dao-ro -L${libdir} +Cflags: -I${includedir}/dpl-efl diff --git a/debian/wrt-commons.postinst b/debian/wrt-commons.postinst index e1eb738..5cadde4 100755 --- a/debian/wrt-commons.postinst +++ b/debian/wrt-commons.postinst @@ -10,14 +10,18 @@ else WRT_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_` AUTOSAVE_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt_autosave.db ".tables" | grep "DB_VERSION_"` AUTOSAVE_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_autosave_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_` + CUSTOM_HANDLER_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt_custom_handler.db ".tables" | grep "DB_VERSION_"` + CUSTOM_HANDLER_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_custom_handler_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_` echo "OLD wrt database version ${WRT_OLD_DB_VERSION}" echo "NEW wrt database version ${WRT_NEW_DB_VERSION}" echo "OLD wrt_autosave database version ${AUTOSAVE_OLD_DB_VERSION}" echo "NEW wrt_autosave database version ${AUTOSAVE_NEW_DB_VERSION}" + echo "OLD wrt_custom_handler database version ${CUSTOM_HANDLER_OLD_DB_VERSION}" + echo "NEW wrt_custom_handler database version ${CUSTOM_HANDLER_NEW_DB_VERSION}" - if [ ${WRT_OLD_DB_VERSION} -a ${WRT_NEW_DB_VERSION} -a ${AUTOSAVE_OLD_DB_VERSION} -a ${AUTOSAVE_NEW_DB_VERSION} ] + if [ ${WRT_OLD_DB_VERSION} -a ${WRT_NEW_DB_VERSION} -a ${AUTOSAVE_OLD_DB_VERSION} -a ${AUTOSAVE_NEW_DB_VERSION} -a ${CUSTOM_HANDLER_OLD_DB_VERSION} -a ${CUSTOM_HANDLER_NEW_DB_VERSION}] then - if [ ${WRT_NEW_DB_VERSION} = ${WRT_OLD_DB_VERSION} -a ${AUTOSAVE_NEW_DB_VERSION} = ${AUTOSAVE_OLD_DB_VERSION} ] + if [ ${WRT_NEW_DB_VERSION} = ${WRT_OLD_DB_VERSION} -a ${AUTOSAVE_NEW_DB_VERSION} = ${AUTOSAVE_OLD_DB_VERSION} -a ${CUSTOM_HANDLER_NEW_DB_VERSION} = ${CUSTOM_HANDLER_OLD_DB_VERSION}] then echo "Equal database detected so db installation ignored" else diff --git a/etc/wrt_commons_create_clean_db.sh b/etc/wrt_commons_create_clean_db.sh index a9d9dc6..d333d9d 100755 --- a/etc/wrt_commons_create_clean_db.sh +++ b/etc/wrt_commons_create_clean_db.sh @@ -14,7 +14,7 @@ # limitations under the License. # -for name in wrt wrt_autosave +for name in wrt wrt_autosave wrt_custom_handler do rm -f /opt/dbspace/.$name.db rm -f /opt/dbspace/.$name.db-journal diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 7e37830..587ba94 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -30,6 +30,7 @@ include(log/config.cmake) ADD_SUBDIRECTORY(widget_dao) ADD_SUBDIRECTORY(auto_save_dao) ADD_SUBDIRECTORY(security_origin_dao) +ADD_SUBDIRECTORY(custom_handler_dao) include(popup/config.cmake) include(utils/config.cmake) include(localization/config.cmake) diff --git a/modules/custom_handler_dao/CMakeLists.txt b/modules/custom_handler_dao/CMakeLists.txt new file mode 100644 index 0000000..a8cdc08 --- /dev/null +++ b/modules/custom_handler_dao/CMakeLists.txt @@ -0,0 +1,79 @@ +ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h + COMMAND ${CMAKE_SOURCE_DIR}/modules/custom_handler_dao/orm/gen_db_md5.sh + ARGS ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h + ${CMAKE_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db + DEPENDS ${CMAKE_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db + ${CMAKE_SOURCE_DIR}/modules/custom_handler_dao/orm/gen_db_md5.sh + COMMENT "Generating WRT custom handlers database checksum" + ) + +ADD_CUSTOM_COMMAND( OUTPUT .wrt_custom_handler.db + COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/.wrt_custom_handler.db + COMMAND gcc -Wall -include ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h -I${PROJECT_SOURCE_DIR}/modules/db/include -I${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm -E ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h | grep --invert-match "^#" > ${CMAKE_CURRENT_BINARY_DIR}/wrt_custom_handler_db.sql + COMMAND sqlite3 ${CMAKE_CURRENT_BINARY_DIR}/.wrt_custom_handler.db ".read ${CMAKE_CURRENT_BINARY_DIR}/wrt_custom_handler_db.sql" || rm -f ${CMAKE_CURRENT_BINARY_DIR}/.wrt_custom_handler.db + DEPENDS ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db + ) + +ADD_CUSTOM_COMMAND( OUTPUT .wrt_custom_handler.db-journal + COMMAND touch + ARGS ${CMAKE_CURRENT_BINARY_DIR}/.wrt_custom_handler.db-journal + ) + +ADD_CUSTOM_TARGET(Sqlite3DbCustomHandler ALL DEPENDS .wrt_custom_handler.db .wrt_custom_handler.db-journal) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wrt_custom_handler_db.sql DESTINATION share/wrt-engine/) + +############################################################################### + +INCLUDE(FindPkgConfig) + +PKG_CHECK_MODULES(CUSTOM_HANDLER_DAO_DEPS + glib-2.0 + REQUIRED) + +SET(CUSTOM_HANDLER_DAO_INCLUDE_DIRS + ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/include + ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm + ${PROJECT_SOURCE_DIR}/modules/core/include + ${PROJECT_SOURCE_DIR}/modules/db/include + ${PROJECT_SOURCE_DIR}/modules/log/include +) + + +SET(CUSTOM_HANDLER_DAO_RO_SOURCES + dao/CustomHandlerDatabase.cpp + dao/custom_handler_dao_read_only.cpp +) + +SET(CUSTOM_HANDLER_DAO_RW_SOURCES + dao/custom_handler_dao.cpp +) + + +INCLUDE_DIRECTORIES(${CUSTOM_HANDLER_DAO_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(SYSTEM ${CUSTOM_HANDLER_DAO_DEPS_INCLUDE_DIRS}) + +ADD_LIBRARY(${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} SHARED ${CUSTOM_HANDLER_DAO_RO_SOURCES}) +SET_TARGET_PROPERTIES(${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} PROPERTIES SOVERSION ${API_VERSION} VERSION ${VERSION}) +SET_TARGET_PROPERTIES(${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} PROPERTIES COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h") +TARGET_LINK_LIBRARIES(${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} ${TARGET_CUSTOM_HANDLER_DAO_LIB}) + +ADD_LIBRARY(${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} SHARED ${CUSTOM_HANDLER_DAO_RW_SOURCES}) +SET_TARGET_PROPERTIES(${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} PROPERTIES SOVERSION ${API_VERSION} VERSION ${VERSION}) +SET_TARGET_PROPERTIES(${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} PROPERTIES COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h") +TARGET_LINK_LIBRARIES(${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} ${TARGET_CUSTOM_HANDLER_DAO_RO_LIB}) + +INSTALL(TARGETS ${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} DESTINATION lib) +INSTALL(TARGETS ${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} DESTINATION lib) + +INSTALL(FILES + include/wrt-commons/custom-handler-dao-ro/common_dao_types.h + include/wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h + include/wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h + DESTINATION include/dpl-efl/wrt-commons/custom-handler-dao-ro +) + +INSTALL(FILES + include/wrt-commons/custom-handler-dao-rw/custom_handler_dao.h + DESTINATION include/dpl-efl/wrt-commons/custom-handler-dao-rw +) diff --git a/modules/custom_handler_dao/dao/CustomHandlerDatabase.cpp b/modules/custom_handler_dao/dao/CustomHandlerDatabase.cpp new file mode 100644 index 0000000..c11f2a0 --- /dev/null +++ b/modules/custom_handler_dao/dao/CustomHandlerDatabase.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2012 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. + */ +#include + +namespace CustomHandlerDB { +namespace Interface { + +namespace { +const char* CustomHandler_DB_DATABASE = "/opt/dbspace/.wrt_custom_handler.db"; +DPL::DB::SqlConnection::Flag::Type CustomHandler_DB_FLAGS = + DPL::DB::SqlConnection::Flag::UseLucene; +} + +DPL::Mutex g_CustomHandlerDbQueriesMutex; +DPL::DB::ThreadDatabaseSupport m_customHandlerdbInterface( + CustomHandler_DB_DATABASE, CustomHandler_DB_FLAGS); + + +void attachDatabaseRO() +{ + m_customHandlerdbInterface.AttachToThread(DPL::DB::SqlConnection::Flag::RO); +} + +void attachDatabaseRW() +{ + m_customHandlerdbInterface.AttachToThread(DPL::DB::SqlConnection::Flag::RW); +} + +void detachDatabase() +{ + m_customHandlerdbInterface.DetachFromThread(); +} + +} //namespace Interface +} //namespace CustomHandlerDB diff --git a/modules/custom_handler_dao/dao/custom_handler_dao.cpp b/modules/custom_handler_dao/dao/custom_handler_dao.cpp new file mode 100644 index 0000000..ee3d52f --- /dev/null +++ b/modules/custom_handler_dao/dao/custom_handler_dao.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2012 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 custom_handler_dao.cpp + * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) + * @version 1.0 + * @brief This file contains the definition of custom handler dao class. + */ + +#include +#include + +namespace CustomHandlerDB { + +CustomHandlerDAO::CustomHandlerDAO(const DPL::String& pkgName) : + CustomHandlerDAOReadOnly(pkgName) +{ +} + +CustomHandlerDAO::~CustomHandlerDAO() +{ +} + +} // namespace CustomHandlerDB diff --git a/modules/custom_handler_dao/dao/custom_handler_dao_read_only.cpp b/modules/custom_handler_dao/dao/custom_handler_dao_read_only.cpp new file mode 100644 index 0000000..2cd5e19 --- /dev/null +++ b/modules/custom_handler_dao/dao/custom_handler_dao_read_only.cpp @@ -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. + */ +/** + * This file contains the declaration of custom handler dao class. + * + * @file custom_handler_dao_read_only.cpp + * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) + * @version 1.0 + * @brief This file contains the declaration of custom handler dao + */ + +#include +#include + +namespace CustomHandlerDB { + +CustomHandlerDAOReadOnly::CustomHandlerDAOReadOnly(const DPL::String& pkgName) +{ +} + +CustomHandlerDAOReadOnly::~CustomHandlerDAOReadOnly() +{ +} + +} // namespace CustomHandlerDB diff --git a/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h new file mode 100644 index 0000000..9b6bd71 --- /dev/null +++ b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2012 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 _CUSTOM_HANDLER_DATABASE_H_ +#define _CUSTOM_HANDLER_DATABASE_H_ + +#include +#include +#include + +extern DPL::Mutex g_CustomHandlerDbQueriesMutex; + +#define CUSTOM_HANDLER_DB_INTERNAL(tlsCommand, InternalType, interface) \ + static DPL::ThreadLocalVariable *tlsCommand ## Ptr = NULL; \ + { \ + DPL::Mutex::ScopedLock lock(&customHandlerDbQueriesMutex); \ + if (!tlsCommand ## Ptr) { \ + static DPL::ThreadLocalVariable tmp; \ + tlsCommand ## Ptr = &tmp; \ + } \ + } \ + DPL::ThreadLocalVariable &tlsCommand = *tlsCommand ## Ptr; \ + if (tlsCommand.IsNull()) { tlsCommand = InternalType(interface); } + +#define CUSTOM_HANDLER_DB_SELECT(name, type, interface) \ + CUSTOM_HANDLER_DB_INTERNAL(name, type::Select, interface) + +#define CUSTOM_HANDLER_DB_INSERT(name, type, interface) \ + CUSTOM_HANDLER_DB_INTERNAL(name, type::Insert, interface) + +#define CUSTOM_HANDLER_DB_UPDATE(name, type, interface) \ + CUSTOM_HANDLER_DB_INTERNAL(name, type::Update, interface) + +#define CUSTOM_HANDLER_DB_DELETE(name, type, interface) \ + CUSTOM_HANDLER_DB_INTERNAL(name, type::Delete, interface) + +namespace CustomHandlerDB { +namespace Interface { + +void attachDatabaseRO(); +void attachDatabaseRW(); +void detachDatabase(); + +extern DPL::DB::ThreadDatabaseSupport m_customHandlerdbInterface; + +} // namespace Interface +} // namespace CustomHandlerDB + +#endif /* _CUSTOM_HANDLER_DATABASE_H_ */ + diff --git a/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/common_dao_types.h b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/common_dao_types.h new file mode 100644 index 0000000..ad55dc1 --- /dev/null +++ b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/common_dao_types.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012 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 common_dao_types.h + * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) + * @version 1.0 + * @brief This file contains the declaration of + * common data types for custom handler database. + */ +#ifndef SHARE_COMMON_DAO_TYPES_H_ +#define SHARE_COMMON_DAO_TYPES_H_ + +namespace CustomHandlerDB { + +} // namespace CustomHandlerDB + +#endif /* SHARE_COMMON_DAO_TYPES_H_ */ diff --git a/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h new file mode 100644 index 0000000..941057b --- /dev/null +++ b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012 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. + */ +/** + * This file contains the declaration of custom handler dao class. + * + * @file custom_handler_dao_read_only.h + * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) + * @version 1.0 + * @brief This file contains the declaration of custom handler dao + */ + +#ifndef _CUSTOM_HANDLER_DAO_READ_ONLY_H_ +#define _CUSTOM_HANDLER_DAO_READ_ONLY_H_ + +#include +#include + +namespace CustomHandlerDB { + +class CustomHandlerDAOReadOnly +{ + public: + /** + * CustomHandlerDAOReadOnly Exception classes + */ + class Exception + { + public: + DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) + DECLARE_EXCEPTION_TYPE(Base, DatabaseError) + }; + + public: + explicit CustomHandlerDAOReadOnly(const DPL::String& pkgName); + virtual ~CustomHandlerDAOReadOnly(); + + // TODO +}; + +} // namespace CustomHandlerDB + +#endif // _CUSTOM_HANDLER_DAO_READ_ONLY_H_ + diff --git a/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-rw/custom_handler_dao.h b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-rw/custom_handler_dao.h new file mode 100644 index 0000000..e192ed7 --- /dev/null +++ b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-rw/custom_handler_dao.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012 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. + */ +/** + * This file contains the declaration of custom handler dao class. + * + * @file custom_handler_dao.h + * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) + * @version 1.0 + * @brief This file contains the declaration of custom handler dao + */ +#ifndef _CUSTOM_HANDLER_DAO_H_ +#define _CUSTOM_HANDLER_DAO_H_ + +#include + +namespace CustomHandlerDB { + +class CustomHandlerDAO : public CustomHandlerDAOReadOnly +{ + public: + explicit CustomHandlerDAO(const DPL::String& pkgName); + virtual ~CustomHandlerDAO(); + + // TODO +}; + +} // namespace CustomHandlerDB + +#endif // _CUSTOM_HANDLER_DAO_H_ diff --git a/modules/custom_handler_dao/orm/custom_handler_db b/modules/custom_handler_dao/orm/custom_handler_db new file mode 100644 index 0000000..6b07417 --- /dev/null +++ b/modules/custom_handler_dao/orm/custom_handler_db @@ -0,0 +1,34 @@ +SQL( + BEGIN TRANSACTION; +) + +CREATE_TABLE(ProtocolHandlers) + COLUMN_NOT_NULL(app_id, TEXT,) + COLUMN_NOT_NULL(target, TEXT,) + COLUMN_NOT_NULL(base_url, TEXT,) + COLUMN_NOT_NULL(url, TEXT,) + COLUMN_NOT_NULL(title, TEXT,) + COLUMN_NOT_NULL(user_allowed, INT,) + + TABLE_CONSTRAINTS( + PRIMARY KEY (app_id, target, url) + ) +CREATE_TABLE_END() + +CREATE_TABLE(ContentHandlers) + COLUMN_NOT_NULL(app_id, TEXT,) + COLUMN_NOT_NULL(target, TEXT,) + COLUMN_NOT_NULL(base_url, TEXT,) + COLUMN_NOT_NULL(url, TEXT,) + COLUMN_NOT_NULL(title, TEXT,) + COLUMN_NOT_NULL(user_allowed, INT,) + + TABLE_CONSTRAINTS( + PRIMARY KEY (app_id, target, url) + ) +CREATE_TABLE_END() + +SQL( + COMMIT; +) + diff --git a/modules/custom_handler_dao/orm/custom_handler_db_definitions b/modules/custom_handler_dao/orm/custom_handler_db_definitions new file mode 100644 index 0000000..1bc2bcd --- /dev/null +++ b/modules/custom_handler_dao/orm/custom_handler_db_definitions @@ -0,0 +1,6 @@ +DATABASE_START(custom_handler) + +#include "custom_handler_db" +#include "version_db" + +DATABASE_END() diff --git a/modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h b/modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h new file mode 100644 index 0000000..9b007de --- /dev/null +++ b/modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2012 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 custom_handler_db_sql_generator.h + * @author Krzysztof Jackiewicz (k.jackiewicz@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 + +#include "custom_handler_db_definitions" diff --git a/modules/custom_handler_dao/orm/gen_db_md5.sh b/modules/custom_handler_dao/orm/gen_db_md5.sh new file mode 100755 index 0000000..22c2530 --- /dev/null +++ b/modules/custom_handler_dao/orm/gen_db_md5.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (c) 2012 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. +# +CHECKSUM=`cat ${2} ${3} 2>/dev/null | md5sum 2>/dev/null | cut -d\ -f1 2>/dev/null` +echo "#define DB_CHECKSUM DB_VERSION_${CHECKSUM}" > ${1} +echo "#define DB_CHECKSUM_STR \"DB_VERSION_${CHECKSUM}\"" >> ${1} + diff --git a/modules/custom_handler_dao/orm/orm_generator_custom_handler.h b/modules/custom_handler_dao/orm/orm_generator_custom_handler.h new file mode 100644 index 0000000..35c43a2 --- /dev/null +++ b/modules/custom_handler_dao/orm/orm_generator_custom_handler.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 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_CUSTOM_HANDLER_H_ +#define _ORM_GENERATOR_CUSTOM_HANDLER_H_ + +#define ORM_GENERATOR_DATABASE_NAME custom_handler_db_definitions +#include +#undef ORM_GENERATOR_DATABASE_NAME + +#endif // _ORM_GENERATOR_CUSTOM_HANDLER_H_ diff --git a/modules/custom_handler_dao/orm/version_db b/modules/custom_handler_dao/orm/version_db new file mode 100644 index 0000000..7e20d8d --- /dev/null +++ b/modules/custom_handler_dao/orm/version_db @@ -0,0 +1,5 @@ +SQL( + BEGIN TRANSACTION; + CREATE TABLE DB_CHECKSUM (version INT); + COMMIT; +) diff --git a/packaging/wrt-commons.spec b/packaging/wrt-commons.spec index 9f3d63e..1758ed2 100644 --- a/packaging/wrt-commons.spec +++ b/packaging/wrt-commons.spec @@ -115,6 +115,8 @@ chsmack -a 'wrt-commons::db_wrt' /opt/dbspace/.wrt.db chsmack -a 'wrt-commons::db_wrt' /opt/dbspace/.wrt.db-journal chsmack -a 'wrt-commons::db_wrt_autosave' /opt/dbspace/.wrt_autosave.db chsmack -a 'wrt-commons::db_wrt_autosave' /opt/dbspace/.wrt_autosave.db-journal +chsmack -a 'wrt-commons::db_wrt_custom_handler' /opt/dbspace/.wrt_custom_handler.db +chsmack -a 'wrt-commons::db_wrt_custom_handler' /opt/dbspace/.wrt_custom_handler.db-journal echo "[WRT] wrt-commons postinst done ..." diff --git a/wrt-commons.manifest b/wrt-commons.manifest index e797580..fb4bfc3 100644 --- a/wrt-commons.manifest +++ b/wrt-commons.manifest @@ -4,6 +4,7 @@