CustomHandlers DAO libraries stubs added
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 30 Nov 2012 13:34:17 +0000 (14:34 +0100)
committerGerrit Code Review <gerrit2@kim11>
Thu, 6 Dec 2012 11:28:47 +0000 (20:28 +0900)
[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

25 files changed:
.gitignore
CMakeLists.txt
build/CMakeLists.txt
build/custom_handler_dao/CMakeLists.txt [new file with mode: 0644]
build/custom_handler_dao/wrt-commons-custom-handler-dao-ro.pc.in [new file with mode: 0644]
build/custom_handler_dao/wrt-commons-custom-handler-dao-rw.pc.in [new file with mode: 0644]
debian/wrt-commons.postinst
etc/wrt_commons_create_clean_db.sh
modules/CMakeLists.txt
modules/custom_handler_dao/CMakeLists.txt [new file with mode: 0644]
modules/custom_handler_dao/dao/CustomHandlerDatabase.cpp [new file with mode: 0644]
modules/custom_handler_dao/dao/custom_handler_dao.cpp [new file with mode: 0644]
modules/custom_handler_dao/dao/custom_handler_dao_read_only.cpp [new file with mode: 0644]
modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h [new file with mode: 0644]
modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/common_dao_types.h [new file with mode: 0644]
modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h [new file with mode: 0644]
modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-rw/custom_handler_dao.h [new file with mode: 0644]
modules/custom_handler_dao/orm/custom_handler_db [new file with mode: 0644]
modules/custom_handler_dao/orm/custom_handler_db_definitions [new file with mode: 0644]
modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h [new file with mode: 0644]
modules/custom_handler_dao/orm/gen_db_md5.sh [new file with mode: 0755]
modules/custom_handler_dao/orm/orm_generator_custom_handler.h [new file with mode: 0644]
modules/custom_handler_dao/orm/version_db [new file with mode: 0644]
packaging/wrt-commons.spec
wrt-commons.manifest

index 9488fa3..fb11196 100755 (executable)
@@ -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
 
index 9a2b37d..06da368 100644 (file)
@@ -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")
index 2e40a76..e11b0e9 100644 (file)
@@ -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 (file)
index 0000000..26e701c
--- /dev/null
@@ -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 (file)
index 0000000..7cda187
--- /dev/null
@@ -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 (file)
index 0000000..4cd2737
--- /dev/null
@@ -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
index e1eb738..5cadde4 100755 (executable)
@@ -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
index a9d9dc6..d333d9d 100755 (executable)
@@ -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
index 7e37830..587ba94 100644 (file)
@@ -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 (file)
index 0000000..a8cdc08
--- /dev/null
@@ -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 (file)
index 0000000..c11f2a0
--- /dev/null
@@ -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 <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+
+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 (file)
index 0000000..ee3d52f
--- /dev/null
@@ -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 <wrt-commons/custom-handler-dao-rw/custom_handler_dao.h>
+#include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+
+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 (file)
index 0000000..2cd5e19
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * 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 <wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h>
+#include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+
+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 (file)
index 0000000..9b6bd71
--- /dev/null
@@ -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 <dpl/thread.h>
+#include <dpl/mutex.h>
+#include <dpl/db/thread_database_support.h>
+
+extern DPL::Mutex g_CustomHandlerDbQueriesMutex;
+
+#define CUSTOM_HANDLER_DB_INTERNAL(tlsCommand, InternalType, interface)      \
+    static DPL::ThreadLocalVariable<InternalType> *tlsCommand ## Ptr = NULL; \
+    {                                                                        \
+        DPL::Mutex::ScopedLock lock(&customHandlerDbQueriesMutex);           \
+        if (!tlsCommand ## Ptr) {                                            \
+            static DPL::ThreadLocalVariable<InternalType> tmp;               \
+            tlsCommand ## Ptr = &tmp;                                        \
+        }                                                                    \
+    }                                                                        \
+    DPL::ThreadLocalVariable<InternalType> &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 (file)
index 0000000..ad55dc1
--- /dev/null
@@ -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 (file)
index 0000000..941057b
--- /dev/null
@@ -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 <dpl/string.h>
+#include <dpl/exception.h>
+
+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 (file)
index 0000000..e192ed7
--- /dev/null
@@ -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 <wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h>
+
+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 (file)
index 0000000..6b07417
--- /dev/null
@@ -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 (file)
index 0000000..1bc2bcd
--- /dev/null
@@ -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 (file)
index 0000000..9b007de
--- /dev/null
@@ -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 <dpl/db/orm_macros.h>
+
+#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 (executable)
index 0000000..22c2530
--- /dev/null
@@ -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 (file)
index 0000000..35c43a2
--- /dev/null
@@ -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 <dpl/db/orm_generator.h>
+#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 (file)
index 0000000..7e20d8d
--- /dev/null
@@ -0,0 +1,5 @@
+SQL(
+    BEGIN TRANSACTION;
+    CREATE TABLE DB_CHECKSUM (version INT);
+    COMMIT;
+)
index 9f3d63e..1758ed2 100644 (file)
@@ -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 ..."
 
index e797580..fb4bfc3 100644 (file)
@@ -4,6 +4,7 @@
     <provide>   
         <label name="wrt-commons::db_wrt"/>
         <label name="wrt-commons::db_wrt_autosave"/>
+        <label name="wrt-commons::db_wrt_custom_handler"/>
     </provide>
   </define>
   <request>