merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:21:44 +0000 (01:21 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:21:44 +0000 (01:21 +0900)
138 files changed:
CMakeLists.txt
data/Daemon.edc
debian/changelog
packaging/wrt.spec
src/api_new/CMakeLists.txt
src/api_new/abstract_context_manager.h [new file with mode: 0644]
src/api_new/core_module.cpp
src/api_new/core_module.h
src/api_new/ewk_context_manager.cpp [new file with mode: 0644]
src/api_new/ewk_context_manager.h [new file with mode: 0644]
src/api_new/i_runnable_widget_object.h
src/api_new/runnable_widget_object.cpp
src/api_new/runnable_widget_object.h
src/api_new/runnable_widget_object_state.cpp
src/api_new/runnable_widget_object_state.h
src/api_new/user_delegates.h [new file with mode: 0644]
src/domain/launch_user_data.h
src/domain/localization_setting.cpp
src/domain/localization_setting.h
src/domain/main_thread.cpp
src/domain/main_thread.h
src/domain/widget_data_types.cpp
src/domain/widget_data_types.h
src/domain/widget_deserialize_model.cpp
src/domain/widget_deserialize_model.h
src/domain/widget_model.cpp
src/domain/widget_model.h
src/plugin-service/wrt_plugin_module.cpp
src/plugin-service/wrt_plugin_module.h
src/profiling/profiling_util.cpp
src/profiling/profiling_util.h
src/profiling/script/profiling-target-part.pl
src/view/common/CMakeLists.txt [changed mode: 0644->0755]
src/view/common/application_data.cpp
src/view/common/application_data.h
src/view/common/application_launcher.cpp [changed mode: 0755->0644]
src/view/common/application_launcher.h
src/view/common/evas_object.cpp
src/view/common/evas_object.h
src/view/common/scheme.cpp
src/view/common/scheme.h
src/view/common/scheme_action_map.cpp
src/view/common/scheme_action_map.h
src/view/common/scheme_action_map_data.h
src/view/common/scheme_action_map_type.h
src/view/common/view_logic_apps_support.cpp
src/view/common/view_logic_apps_support.h
src/view/common/view_logic_certificate_support.cpp [new file with mode: 0755]
src/view/common/view_logic_certificate_support.h [new file with mode: 0755]
src/view/common/view_logic_custom_header_support.cpp
src/view/common/view_logic_custom_header_support.h
src/view/common/view_logic_geolocation_support.cpp
src/view/common/view_logic_geolocation_support.h
src/view/common/view_logic_password_support.cpp
src/view/common/view_logic_password_support.h
src/view/common/view_logic_security_origin_support.cpp
src/view/common/view_logic_security_origin_support.h
src/view/common/view_logic_security_support.cpp
src/view/common/view_logic_security_support.h
src/view/common/view_logic_storage_support.cpp
src/view/common/view_logic_storage_support.h
src/view/common/view_logic_uri_support.cpp
src/view/common/view_logic_uri_support.h
src/view/common/view_logic_user_agent_support.cpp
src/view/common/view_logic_user_agent_support.h
src/view/common/view_logic_vibration_support.cpp
src/view/common/view_logic_vibration_support.h
src/view/i_view_module.h [changed mode: 0755->0644]
src/view/view_module.cpp
src/view/webkit/CMakeLists.txt
src/view/webkit/bundles/CMakeLists.txt
src/view/webkit/bundles/bundle_uri_handling.cpp
src/view/webkit/bundles/bundle_uri_handling.h
src/view/webkit/bundles/messages_names.h
src/view/webkit/bundles/plugin_module_support.cpp
src/view/webkit/bundles/plugin_module_support.h
src/view/webkit/bundles/wrt-wk2-bundle.cpp
src/view/webkit/bundles/wrt-wk2-bundle.h
src/view/webkit/view_logic.cpp [changed mode: 0755->0644]
src/view/webkit/view_logic.h
src/view/webkit/view_logic_authentication_challenge_support.cpp [new file with mode: 0644]
src/view/webkit/view_logic_authentication_challenge_support.h [moved from src/view/webkit/view_logic_filesystem_support.h with 63% similarity]
src/view/webkit/view_logic_certificate_confirm_support.cpp [new file with mode: 0755]
src/view/webkit/view_logic_certificate_confirm_support.h [moved from src/view/webkit/view_logic_web_storage_support.h with 60% similarity, mode: 0755]
src/view/webkit/view_logic_filesystem_support.cpp [deleted file]
src/view/webkit/view_logic_geolocation_support_webkit2.cpp
src/view/webkit/view_logic_geolocation_support_webkit2.h
src/view/webkit/view_logic_scheme_support.cpp
src/view/webkit/view_logic_scheme_support.h
src/view/webkit/view_logic_usermedia_support.cpp
src/view/webkit/view_logic_usermedia_support.h
src/view/webkit/view_logic_utils.cpp [deleted file]
src/view/webkit/view_logic_utils.h [deleted file]
src/view/webkit/view_logic_web_notification_support.cpp
src/view/webkit/view_logic_web_notification_support.h
src/view/webkit/view_logic_web_storage_support.cpp [deleted file]
src/wrt-client/splash_screen_support.cpp
src/wrt-client/splash_screen_support.h
src/wrt-client/window_data.cpp [changed mode: 0755->0644]
src/wrt-client/window_data.h [changed mode: 0755->0644]
src/wrt-client/wrt-client.cpp [changed mode: 0755->0644]
src/wrt-client/wrt-client.h [changed mode: 0755->0644]
src/wrt-launcher/wrt-launcher.cpp
src/wrt-launchpad-daemon/feature/preexec.h
src/wrt-launchpad-daemon/include/app_signal.h
src/wrt-launchpad-daemon/include/app_sock.h
src/wrt-launchpad-daemon/include/aul_util.h
src/wrt-launchpad-daemon/include/menu_db_util.h
src/wrt-launchpad-daemon/include/perf.h
src/wrt-launchpad-daemon/include/simple_util.h
src/wrt-launchpad-daemon/launchpad_src/access_control.h
src/wrt-launchpad-daemon/launchpad_src/config.h
src/wrt-launchpad-daemon/launchpad_src/gl.h
src/wrt-launchpad-daemon/launchpad_src/launchpad.c
src/wrt-launchpad-daemon/launchpad_src/sigchild.h
src/wrt-launchpad-daemon/launchpad_src/util_x.c
src/wrt-launchpad-daemon/launchpad_src/util_x.h
src/wrt-launchpad-daemon/legacy/preload.h
src/wrt-launchpad-daemon/src/app_sock.c
src/wrt-launchpad-daemon/src/simple_util.c
tests/CMakeLists.txt [new file with mode: 0644]
tests/widgets/CMakeLists.txt [new file with mode: 0644]
tests/widgets/CMakeUtils.txt [new file with mode: 0644]
tests/widgets/TestCases.cpp [new file with mode: 0644]
tests/widgets/TestInit.cpp [new file with mode: 0644]
tests/widgets/common/CMakeLists.txt [new file with mode: 0644]
tests/widgets/common/include/InstallerWrapper.h [new file with mode: 0644]
tests/widgets/common/include/RunnableObjectStateTester.h [new file with mode: 0644]
tests/widgets/common/include/mock/MockContextManager.h [new file with mode: 0644]
tests/widgets/common/include/mock/MockViewModule.h [new file with mode: 0644]
tests/widgets/common/src/InstallerWrapper.cpp [new file with mode: 0644]
tests/widgets/common/src/RunnableObjectStateTester.cpp [new file with mode: 0644]
tests/widgets/common/src/mock/MockContextManager.cpp [new file with mode: 0644]
tests/widgets/common/src/mock/MockViewModule.cpp [new file with mode: 0644]
tests/widgets/files/CMakeLists.txt [new file with mode: 0644]
tests/widgets/files/any.wgt [new file with mode: 0644]
uncrustify.cfg [new file with mode: 0644]
uncrustify.sh [new file with mode: 0755]

index 408bfc7..2350e23 100644 (file)
@@ -41,7 +41,12 @@ IF(NOT CMAKE_BUILD_TYPE)
 ENDIF(NOT CMAKE_BUILD_TYPE)
 
 OPTION(DPL_LOG "DPL logs status" ON)
-
+OPTION(WITH_TESTS "Build tests" OFF)
+#enable csp policy support
+OPTION(CSP_SUPPORT "Support for csp policy" ON)
+IF(CSP_SUPPORT)
+    ADD_DEFINITIONS("-DCSP_ENABLED")
+ENDIF(CSP_SUPPORT)
 # logs can be only enabled in debug mode
 IF(CMAKE_BUILD_TYPE MATCHES "Profiling" AND DPL_LOG)
     MESSAGE(STATUS "Logging disabled for DPL")
@@ -50,6 +55,7 @@ ELSE(CMAKE_BUILD_TYPE MATCHES "Profiling" AND DPL_LOG)
     MESSAGE(STATUS "Logging enabled for DPL")
 ENDIF(CMAKE_BUILD_TYPE MATCHES "Profiling" AND DPL_LOG)
 
+MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS})
 MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
 OPTION(PROFILING "Profiling status" OFF)
 IF(CMAKE_BUILD_TYPE MATCHES "Profiling")
@@ -230,10 +236,19 @@ INSTALL(FILES   ${PROJECT_SOURCE_DIR}/data/generic_popup_horizontal.edj
 ADD_SUBDIRECTORY(src)
 ADD_SUBDIRECTORY(po)
 
-set(PKGCONFIG_DIR ${PROJECT_SOURCE_DIR}/pkgconfig)
+SET(WRT_API_NEW_INCLUDES
+    "${PROJECT_SOURCE_DIR}/src/api_new/"
+    "${PROJECT_SOURCE_DIR}/src/domain/"
+    "${PROJECT_SOURCE_DIR}/src/view/")
+
+SET(PKGCONFIG_DIR ${PROJECT_SOURCE_DIR}/pkgconfig)
 
 CONFIGURE_FILE(${PKGCONFIG_DIR}/wrt-core.pc.in
     ${PKGCONFIG_DIR}/wrt-core.pc @ONLY)
 INSTALL(FILES ${PKGCONFIG_DIR}/wrt-core.pc DESTINATION lib/pkgconfig)
 
+IF(WITH_TESTS)
+    add_subdirectory(tests)
+ENDIF(WITH_TESTS)
+
 
index c3c94dc..84af808 100644 (file)
@@ -270,4 +270,144 @@ collections {
             }
         }
     }
+    group {
+        name: "authChallengePopup";
+        parts {
+            part {
+                name : "bg";
+                type : RECT;
+                scale : 1;
+                description {
+                    state : "default" 0.0;
+                    align : 0.0 0.0;
+                    min :  0 450;
+                    color : 0 0 0 0;
+                    rel1 { relative: 0.0 0.0; }
+                    rel2 { relative: 1.0 1.0; }
+                }
+            }
+            part{
+                name :"elm.swallow.label";
+                scale : 1;
+                type : SWALLOW;
+                description {
+                    state : "default" 0.0;
+                    align : 0.0 0.0;
+                    rel1 { relative: 0.0 0.0; to: "bg"; }
+                    rel2 { relative: 1.0 0.0; to: "bg"; }
+                }
+            }
+            part {
+                name: "pad_m";
+                scale : 1;
+                description {
+                    state: "default" 0.0;
+                    align: 0.0 0.0;
+                    min: 250 30;
+                    fixed: 0 1;
+                    rel1 { relative: 0.0 1.0; to: "elm.swallow.label"; }
+                    rel2 { relative: 1.0 1.0; to: "elm.swallow.label"; }
+                }
+            }
+            part {
+                name:"spacet_to_idfield";
+                type: RECT;
+                scale : 1;
+                description {
+                    state: "default" 0.0;
+                    color: 0 0 0 0;
+                    min: 200 40;
+                    align: 0.0 0.0;
+                    rel1 { relative: 0.0 1.0; to: "pad_m"; }
+                    rel2 { relative: 1.0 1.0; to: "pad_m"; }
+                }
+            }
+            part {
+                name:"idfield_text";
+                type: TEXT;
+                scale : 1;
+                description {
+                    state: "default" 0.0;
+                    color: 168 168 168 255;
+                    text {
+                        font: "Tizen:style=Medium";
+                        size: 35;
+                        align: 0.0 0.0;
+                    }
+                    min: 200 40;
+                    align: 0.0 0.0;
+                    rel1 { relative: 0.0 1.0; to: "pad_m"; }
+                    rel2 { relative: 0.4 1.0; to: "pad_m"; }
+                }
+            }
+            part{
+                name:"elm.swallow.idfield";
+                type: SWALLOW;
+                scale : 1;
+                description {
+                    state: "default" 0.0;
+                    min: 200 40;
+                    align: 0.0 0.0;
+                    rel1 { relative: 0.35 0.38; to: "pad_m"; }
+                    rel2 { relative: 1.0 0.38; to: "pad_m"; }
+                }
+            }
+            part {
+                name: "pad_text";
+                scale : 1;
+                description {
+                    state: "default" 0.0;
+                    align: 0.0 0.0;
+                    min: 250 38;
+                    fixed: 0 1;
+                    rel1 { relative: 0.0 1.0; to: "spacet_to_idfield"; }
+                    rel2 { relative: 1.0 1.0; to: "spacet_to_idfield"; }
+                }
+            }
+            part{
+                name:"passwdfield_text";
+                type: TEXT;
+                scale : 1;
+                description {
+                    state: "default" 0.0;
+                    color: 168 168 168 255;
+                    text {
+                        font: "Tizen:style=Medium";
+                        size: 35;
+                        align: 0.0 1.0;
+                    }
+                    min: 200 40;
+                    align: 0.0 0.0;
+                    fixed: 0 0;
+                    rel1 { relative: 0.0 1.0; to: "pad_text"; }
+                    rel2 { relative: 0.4 1.0; to: "pad_text"; }
+                }
+            }
+            part {
+                name: "elm.swallow.passwdfield";
+                type: SWALLOW;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    min: 250 40;
+                    align: 0.0 0.0;
+                    fixed: 0 0;
+                    rel1 { relative: 0.35 0.25; to: "pad_text"; }
+                    rel2 { relative: 1.0 0.25; to: "pad_text"; }
+                }
+            }
+            part {
+                name: "pad_b";
+                scale : 1;
+                description {
+                    state: "default" 0.0;
+                    align: 0.0 1.0;
+                    min: 0 5;
+                    fixed: 0 1;
+                    rel1 { relative: 0.0 1.0; to: "bg"; }
+                    rel2 { relative: 1.0 1.0; to: "bg"; }
+                }
+            }
+        }
+    }
 }//end of collection
index 833a909..1dbd35c 100644 (file)
@@ -1,3 +1,133 @@
+wrt (0.8.162) unstable; urgency=low
+
+  * Add unknown scheme handler
+  * Implement privilege for usermedia permission
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 15 Mar 2013 12:52:19 +0900
+
+wrt (0.8.161) unstable; urgency=low
+
+  * Update unmerged source code
+  * Temporary turn off default policy for CSP
+  * Fix for race condition issue when widget is pausing
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 14 Mar 2013 17:00:07 +0900
+
+wrt (0.8.160) unstable; urgency=low
+
+  * CSP enabled
+  * CSP-report-only support enabled
+  * Fixed wrong mailto scheme action
+  * Fixed download manager launch fail issue
+  * Wildcard character support in app-control uri
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 13 Mar 2013 10:22:04 +0900
+
+wrt (0.8.159) unstable; urgency=low
+
+  * remove dependency encryption library from wrt-commons 
+
+ -- leerang <leerang.song@samsung.com>  Mon, 11 Mar 2013 20:00:19 +0900
+
+wrt (0.8.158) unstable; urgency=low
+
+  * Release
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 11 Mar 2013 16:01:17 +0900
+
+wrt (0.8.157) unstable; urgency=low
+
+  * Set proper title to page on handling tizen scheme
+  * Implement certificate confirm popup
+
+ -- leerang <leerang.song@samsung.com>  Mon, 11 Mar 2013 13:40:36 +0900
+
+wrt (0.8.156) unstable; urgency=low
+
+  * PluginModuleSupport::init fix for multiple webkit context (part.2)
+  * Profiling fix
+  * Fixed plugin load fail issue during suspend
+  * 'on_frame_unload' plugin's callback is not invoked when webapp is terminated.
+  * Implement authentication challenge popup
+  * Replace getUserMedia API
+  * Replace geolocation API
+  * Replace web notification API
+  * Change decryption API
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 08 Mar 2013 16:56:42 +0900
+
+wrt (0.8.155) unstable; urgency=low
+
+  * Fix App-control Supports
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 07 Mar 2013 09:15:01 +0900
+
+wrt (0.8.154) unstable; urgency=low
+
+  * DPL static block usage for profiling
+  * Analysing and removing cppcheck warnings in wrt repository
+  * Enable wrt::RunnableWidgetObject tests
+  * Fixed fail to connect external address (http, https)
+  * Remove filesystem usage popup
+  * Remove web storage usage popup
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 06 Mar 2013 17:26:48 +0900
+
+wrt (0.8.153) unstable; urgency=low
+
+  * Added the initial value for ewk orientation
+  * change webview setting regarding automatically fitting content to device wdith
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 27 Feb 2013 17:44:58 +0900
+
+wrt (0.8.152) unstable; urgency=low
+
+  * Fix bug regarding app service on specific scenario
+  * Fix the problem of browser launch when webapp can't access remote url by WARP
+  * Analysing and removing compilation warnings in wrt repository 
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Fri, 22 Feb 2013 11:05:22 +0900
+
+wrt (0.8.151) unstable; urgency=low
+
+  * PluginModuleSupport::init fix for multiple webkit context
+  * Fixed wrt-launcher -l
+  * [LINUXWRT-110][CID: 44047] Prevent fixes
+  * [LINUXWRT-110][CID: 44006] Prevent fixes
+  * Renaming tests binaries
+  * Prepare wrt to handle csp policy rules.
+  * Support multiple webkit context on wrt-core
+  * Moving RunnableWidgetObject tests from wrt-extra to wrt
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Thu, 21 Feb 2013 20:51:45 +0900
+
+wrt (0.8.150) unstable; urgency=low
+
+  * Fix visibility change event when window open and close
+  * Fix Tizen device API access in window.onunload callback
+  * Prevent issues fixes - wrt-launchpad-deamon
+  * Source code formating unification
+  * Disable context options regarding opening new webview
+  * Change of reference vconf key for default user agent value.
+  * Prevent issues fixes
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Wed, 13 Feb 2013 15:23:20 +0900
+
+wrt (0.8.149) unstable; urgency=low
+
+  * Update background-support app's memory policy and reorganize some code
+  * Crash Fix when Creating SecurityOrigin DB.
+  * fix the issue that web app can't rotate
+  * separate evas window construction and initialization
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Fri, 01 Feb 2013 15:23:21 +0900
+
+wrt (0.8.148) unstable; urgency=low
+
+  * Change pkgname to appid
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 28 Jan 2013 17:52:30 +0900
+
 wrt (0.8.147) unstable; urgency=low
 
   * Adding the plugin loading init in reset widget process
index 7c5e970..d03810f 100644 (file)
@@ -1,7 +1,7 @@
-#git:framework/web/wrt wrt_0.8.148.1
+#git:framework/web/wrt wrt_0.8.162
 Name:       wrt
 Summary:    web runtime
-Version:    0.8.148.1
+Version:    0.8.162
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
@@ -43,6 +43,10 @@ BuildRequires:  pkgconfig(wrt-plugin-js-overlay)
 BuildRequires:  pkgconfig(dpl-encryption)
 BuildRequires:  pkgconfig(wrt-popup-wrt-runner)
 BuildRequires:  pkgconfig(wrt-popup-ace-runner)
+BuildRequires:  pkgconfig(sysman)
+BuildRequires:  pkgconfig(osp-appfw)
+BuildRequires:  osp-appfw-internal-devel
+Requires: osp-appfw
 
 ## wrt-launchpad-daemon #######################################################
 BuildRequires:  pkgconfig(app-checker)
@@ -69,13 +73,19 @@ wrt library development headers
 %prep
 %setup -q
 
+%define with_tests 0
+%if "%{WITH_TESTS}" == "ON" || "%{WITH_TESTS}" == "Y" || "%{WITH_TESTS}" == "YES" || "%{WITH_TESTS}" == "TRUE" || "%{WITH_TESTS}" == "1"
+    %define with_tests 1
+%endif
+
 %build
 export LDFLAGS+="-Wl,--rpath=/usr/lib"
 
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
         -DDPL_LOG="ON"                    \
         -DPROJECT_VERSION=%{version} \
-        -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
+        -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
+        %{?WITH_TESTS:-DWITH_TESTS=%WITH_TESTS}
 make %{?jobs:-j%jobs}
 
 %install
@@ -149,6 +159,10 @@ systemctl daemon-reload
 %attr(644,root,root) %{_datadir}/edje/wrt/*
 %attr(644,root,root) %{_datadir}/edje/ace/*
 %attr(644,root,root) /usr/etc/wrt/*
+%if %{with_tests}
+    %attr(755,root,root) %{_bindir}/wrt-tests-general
+    /opt/share/widget/tests/general/*
+%endif
 
 ## wrt-launchpad-daemon #######################################################
 %attr(755,root,root) %{_bindir}/wrt_launchpad_daemon
index 2aa2a27..f5af14a 100644 (file)
@@ -17,6 +17,7 @@ ADD_LIBRARY(${TARGET_CORE_MODULE_LIB} SHARED
     ${PROJECT_SOURCE_DIR}/src/api_new/core_module.cpp
     ${PROJECT_SOURCE_DIR}/src/api_new/runnable_widget_object.cpp
     ${PROJECT_SOURCE_DIR}/src/api_new/runnable_widget_object_state.cpp
+    ${PROJECT_SOURCE_DIR}/src/api_new/ewk_context_manager.cpp
 )
 
 SET_TARGET_PROPERTIES(${TARGET_CORE_MODULE_LIB} PROPERTIES
@@ -63,5 +64,6 @@ INSTALL(TARGETS ${TARGET_CORE_MODULE_LIB}
 INSTALL(FILES
     ${PROJECT_SOURCE_DIR}/src/api_new/core_module.h
     ${PROJECT_SOURCE_DIR}/src/api_new/i_runnable_widget_object.h
+    ${PROJECT_SOURCE_DIR}/src/api_new/user_delegates.h
     DESTINATION include/${PROJECT_NAME}
 )
diff --git a/src/api_new/abstract_context_manager.h b/src/api_new/abstract_context_manager.h
new file mode 100644 (file)
index 0000000..555eb86
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    abstract_context_manager.h
+ * @author  Iwanek Tomasz (t.iwanek@samsung.com)
+ * @version 0.1
+ * @brief   Abstract file for handling operation regarding Ewk_Context.
+ */
+
+#ifndef ABSTRACT_CONTEXT_MANAGER_H
+#define ABSTRACT_CONTEXT_MANAGER_H
+
+#include <memory>
+#include <functional>
+#include <ewk_context.h>
+#include <i_view_module.h>
+
+namespace WRT {
+
+class AbstractContextManager;
+typedef std::shared_ptr<AbstractContextManager> ContextManagerPtr;
+
+typedef std::function<ContextManagerPtr (const std::string&, Ewk_Context*, ViewModule::IViewModulePtr)> ContextManagerFactoryMethod;
+
+/**
+ * @brief The AbstractContextManager class Factory for ewk context
+ *
+ * This is interface class for ewk context factory.
+ * It's uses tizenId, view module to initialize it approriatly context.
+ *
+ * Constructor should create new context only if ewkContext parameter is NULL.
+ * If ewkContext parameter is not NULL, context should not be destroyed in destructor.
+ * This means used context is managed by manager only if was created internally.
+ *
+ * NOTE: This interface in not visible outside core module and it should not be.
+ *       Reason for this code is not modify RunnableWidgetObject behaviour for mocks.
+ */
+class AbstractContextManager {
+public:
+    AbstractContextManager(
+            const std::string& tizenAppId,
+            Ewk_Context* ewkContext,
+            ViewModule::IViewModulePtr viewModule) :
+            m_appId(tizenAppId), m_ewkContext(ewkContext), m_view(viewModule) {}
+    virtual ~AbstractContextManager() {}
+    /**
+     * @brief getEwkContext returns ewk context
+     * @return ewk context
+     */
+    virtual Ewk_Context* getEwkContext() const = 0;
+    /**
+     * @brief handleLowMemory
+     *
+     * Handles low memory conditions
+     */
+    virtual void handleLowMemory() = 0;
+protected:
+    std::string m_appId;
+    Ewk_Context* m_ewkContext;
+    ViewModule::IViewModulePtr m_view;
+};
+
+template<class T> ContextManagerPtr contextManagerFactoryMethod(const std::string& id, Ewk_Context* c, ViewModule::IViewModulePtr view)
+{
+    return ContextManagerPtr( new T(id, c, view) );
+}
+
+template<class T> ContextManagerFactoryMethod makeContextManagerFactoryMethod()
+{
+    return contextManagerFactoryMethod<T>;
+}
+
+}
+
+#endif // ABSTRACT_CONTEXT_MANAGER_H
index ee8c350..73a8c75 100644 (file)
 
 #include <EWebKit2.h>
 
-
 IMPLEMENT_SINGLETON(WRT::CoreModule)
 
 namespace { //Anonymous
-
 const char * const bundlePath = "/usr/lib/wrt-wk2-bundles/libwrt-wk2-bundle.so";
 
 std::string cutOffFileName(const std::string& path)
@@ -85,17 +83,16 @@ bool checkPaths()
     if_ok &= (isDir(GetUserInstalledWidgetPath()));
     if (!if_ok) {
         LogError("Path <" << GetUserInstalledWidgetPath() <<
-            "> does not exist.");
+                 "> does not exist.");
     }
     return if_ok;
 }
-}// namespace anonymous
+} // namespace anonymous
 
 namespace WRT {
-
 class CoreModuleImpl
 {
-public:
+  public:
 
     CoreModuleImpl() : m_initialized(false), m_ewkContext(NULL)
     {
@@ -119,38 +116,9 @@ public:
             }
             Try
             {
-                if(!m_ewkContext)
-                {
-                    // Needed settings for WKContext are located here
-                    // create Ewk_Context
-                    Ewk_Context* newEwkContext =
-                        ewk_context_new_with_injected_bundle_path(bundlePath);
-                    if (!newEwkContext) {
-                        LogError("Failed to create Ewk_Context");
-                        ThrowMsg(DPL::Exception, "Failed to create ewk context");
-                    }
-
-                    m_ewkContext = newEwkContext;
-                }
-
-                // cache model setting
-                ewk_context_cache_model_set(m_ewkContext,
-                                            EWK_CACHE_MODEL_DOCUMENT_BROWSER);
-                ADD_PROFILING_POINT("WebProcess fork", "start");
-
-                // To fork a Webprocess as soon as possible,
-                // the following ewk_api is called explicitly.
-                Ewk_Cookie_Manager *ewkCookieManager;
-                ewkCookieManager =
-                    ewk_context_cookie_manager_get(m_ewkContext);
-                ewk_cookie_manager_accept_policy_set(ewkCookieManager,
-                                               EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
-                ADD_PROFILING_POINT("WebProcess fork", "stop");
-
                 ADD_PROFILING_POINT("attach databases", "start");
                 MainThreadSingleton::Instance().AttachDatabases();
                 ADD_PROFILING_POINT("attach databases", "stop");
-
                 LogDebug("Initialize finished");
             } catch (const DPL::Exception& ex) {
                 LogError("Internal Error during screen preparation:");
@@ -158,7 +126,7 @@ public:
                 /* TODO:
                  * Do deinitialization: check on which step exception occured
                  * and deinitialize only initialized parts.
-                */
+                 */
                 return false;
             }
             m_initialized = true;
@@ -166,38 +134,20 @@ public:
         return true;
     }
 
-    bool Init(Ewk_Context* ewk_context)
-    {
-        if(ewk_context)
-        {
-            m_ewkContext = ewk_context;
-        }
-
-        return Init();
-    }
-
     void Terminate()
     {
-        if (m_ewkContext) {
-            LogInfo("finalizeEwkContext called");
-            ewk_context_delete(m_ewkContext);
-            m_ewkContext = 0;
-        }
         MainThreadSingleton::Instance().DetachDatabases();
-
         m_initialized = false;
     }
 
     RunnableWidgetObjectPtr getRunnableWidgetObject(
-            const std::string& tizenId)
+        const std::string& tizenId)
     {
-        PluginModuleSupport::init(m_ewkContext, tizenId);
-
         try {
             RunnableWidgetObjectPtr runnable;
             WidgetModelPtr model = Domain::deserializeWidgetModel(tizenId);
             if (!!model) {
-                runnable.reset(new RunnableWidgetObject(model, m_ewkContext));
+                runnable.reset(new RunnableWidgetObject(model));
             }
             return runnable;
         } catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) {
@@ -243,36 +193,29 @@ public:
         return WrtDB::GlobalDAOReadOnly::GetDeveloperMode();
     }
 
-private:
+  private:
     bool m_initialized;
     Ewk_Context* m_ewkContext;
 };
 
 CoreModule::CoreModule() : m_impl(new CoreModuleImpl())
-{
-}
+{}
 
 CoreModule::~CoreModule()
-{
-}
+{}
 
 bool CoreModule::Init()
 {
     return m_impl->Init();
 }
 
-bool CoreModule::Init(Ewk_Context* ewk_context)
-{
-    return m_impl->Init(ewk_context);
-}
-
 void CoreModule::Terminate()
 {
     return m_impl->Terminate();
 }
 
 RunnableWidgetObjectPtr CoreModule::getRunnableWidgetObject(
-        const std::string& tizenId)
+    const std::string& tizenId)
 {
     return m_impl->getRunnableWidgetObject(tizenId);
 }
@@ -291,5 +234,4 @@ bool CoreModule::developerMode()
 {
     return m_impl->developerMode();
 }
-
 } /* namespace WRT */
index f436012..026b289 100644 (file)
@@ -32,7 +32,6 @@
 #include <EWebKit2.h>
 
 namespace WRT {
-
 class CoreModuleImpl; // forward declaration
 
 class CoreModule
@@ -55,7 +54,6 @@ class CoreModule
      * @return true on success, false when it fails
      */
     bool Init();
-    bool Init(Ewk_Context* ewk_context);
     /**
      * Deinitialize CoreModule. If it called without Init() some internal
      * asserts will fail.
@@ -69,7 +67,7 @@ class CoreModule
      * @return NULL on fail
      */
     RunnableWidgetObjectPtr getRunnableWidgetObject(
-            const std::string& tizenId);
+        const std::string& tizenId);
     /**
      * Gets from database global property of homeNetworkAccess
      * @return homeNetworkAccess value
@@ -95,6 +93,5 @@ class CoreModule
 };
 
 typedef DPL::Singleton<CoreModule> CoreModuleSingleton;
-
 } /* namespace WRT */
 #endif /* CORE_MODULE_H_ */
diff --git a/src/api_new/ewk_context_manager.cpp b/src/api_new/ewk_context_manager.cpp
new file mode 100644 (file)
index 0000000..d1ae016
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    ewk_context_manager.cpp
+ * @author  Yunchan Cho (yunchan.cho@samsung.com)
+ * @version 0.1
+ * @brief   Implementation of EwkContextManager class.
+ *          This file handles operation regarding Ewk_Context
+ */
+
+#include <string>
+#include <vconf.h>
+#include <ewk_context.h>
+#include <dpl/log/log.h>
+#include <dpl/exception.h>
+#include <profiling_util.h>
+#include <i_view_module.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/wrt-dao-ro/vconf_config.h>
+#include <dpl/utils/wrt_global_settings.h>
+#include "ewk_context_manager.h"
+
+namespace WRT {
+
+static const std::string bundlePath("/usr/lib/wrt-wk2-bundles/libwrt-wk2-bundle.so");
+static const std::string caCertPath("/opt/usr/share/certs/ca-certificate.crt");
+
+EwkContextManager::EwkContextManager(
+        const std::string& tizenAppId,
+        Ewk_Context* ewkContext,
+        ViewModule::IViewModulePtr viewModule)
+    : AbstractContextManager(tizenAppId, ewkContext, viewModule),
+      m_initialized(false), m_isInternalContext(false)
+{
+    if (!initialize()) {
+        ThrowMsg(DPL::Exception, "Fail to intialize EwkContextManager");
+    }
+    // set ewk context callbacks
+    setCallbacks();
+}
+
+EwkContextManager::~EwkContextManager()
+{
+    // unset registered ewk context callbacks
+    unsetCallbacks();
+    destroy();
+}
+
+Ewk_Context * EwkContextManager::getEwkContext() const
+{
+    return m_ewkContext;
+}
+
+bool EwkContextManager::initialize()
+{
+    if (!m_ewkContext) {
+        m_ewkContext = ewk_context_new_with_injected_bundle_path(bundlePath.c_str());
+
+        if (!m_ewkContext) {
+            return false;
+        }
+
+        m_isInternalContext = true;
+    }
+
+    // cache model setting
+    ewk_context_cache_model_set(
+            m_ewkContext,
+            EWK_CACHE_MODEL_DOCUMENT_BROWSER);
+    ADD_PROFILING_POINT("WebProcess fork", "start");
+    // To fork a Webprocess as soon as possible,
+    // the following ewk_api is called explicitly.
+    ewk_cookie_manager_accept_policy_set(
+            ewk_context_cookie_manager_get(m_ewkContext),
+            EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+    ADD_PROFILING_POINT("WebProcess fork", "stop");
+
+    // proxy server setting
+    char *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
+    if (proxy && strlen(proxy) && strcmp(proxy, "0.0.0.0")) {
+        LogInfo("proxy address: " << proxy);
+        ewk_context_proxy_uri_set(m_ewkContext,  proxy);
+    } else {
+        LogInfo("proxy address is empty");
+        ewk_context_proxy_uri_set(m_ewkContext, NULL);
+    }
+
+    if (proxy) {
+        free(proxy);
+    }
+
+    ewk_context_certificate_file_set(m_ewkContext, caCertPath.c_str());
+
+    // set local stroage database path
+    WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(m_appId));
+    ewk_context_web_storage_path_set(
+            m_ewkContext,
+            dao.getPrivateLocalStoragePath().c_str());
+
+    // memory saving mode
+    int result;
+    vconf_get_int(
+            WrtDB::VconfConfig::GetVconfKeyMemorySavingMode(
+                DPL::FromUTF8String(m_appId)).c_str(), &result);
+
+    ewk_context_memory_saving_mode_set(
+            m_ewkContext,
+            static_cast<WrtDB::SettingsType>(result) ==
+            WrtDB::SETTINGS_TYPE_ON ? EINA_TRUE : EINA_FALSE);
+
+    m_initialized = true;
+
+    return true;
+}
+
+void EwkContextManager::destroy()
+{
+    // only in the following case, webkit context should be deleted
+    if (m_initialized && m_isInternalContext) {
+        ewk_context_delete(m_ewkContext);
+    }
+}
+
+void EwkContextManager::setCallbacks()
+{
+    if (!m_initialized) {
+        return;
+    }
+
+    ewk_context_message_from_injected_bundle_callback_set(
+            m_ewkContext,
+            messageFromInjectedBundleCallback,
+            this);
+
+    ewk_context_did_start_download_callback_set(
+            m_ewkContext,
+            didStartDownloadCallback,
+            this);
+
+    ewk_context_vibration_client_callbacks_set(
+            m_ewkContext,
+            vibrationClientStartCallback,
+            vibrationClientStopCallback,
+            this);
+}
+
+void EwkContextManager::unsetCallbacks()
+{
+    if (!m_initialized) {
+        return;
+    }
+
+    ewk_context_message_from_injected_bundle_callback_set(
+            m_ewkContext, NULL, NULL);
+    ewk_context_did_start_download_callback_set(
+            m_ewkContext, NULL, NULL);
+    ewk_context_vibration_client_callbacks_set(
+            m_ewkContext, NULL, NULL, NULL);
+}
+
+
+void EwkContextManager::messageFromInjectedBundleCallback(
+        const char* name,
+        const char* body,
+        char** returnData,
+        void* clientInfo)
+{
+    LogDebug("enter");
+    LogDebug("did recive message: " << name);
+
+    EwkContextManager* This = static_cast<EwkContextManager*>(clientInfo);
+    This->m_view->checkSyncMessageFromBundle(name, body, returnData);
+}
+
+void EwkContextManager::didStartDownloadCallback(const char* downloadUrl, void* data)
+{
+    LogDebug("enter");
+    LogDebug("download url: " << downloadUrl);
+
+    EwkContextManager* This = static_cast<EwkContextManager*>(data);
+    This->m_view->downloadData(downloadUrl);
+}
+
+void EwkContextManager::vibrationClientStartCallback(uint64_t time, void* data)
+{
+    LogDebug("enter");
+
+    EwkContextManager* This = static_cast<EwkContextManager*>(data);
+    This->m_view->activateVibration(true, static_cast<long>(time));
+}
+
+void EwkContextManager::vibrationClientStopCallback(void* data)
+{
+    LogDebug("enter");
+
+    EwkContextManager* This = static_cast<EwkContextManager*>(data);
+    This->m_view->activateVibration(false, 0);
+}
+
+void EwkContextManager::handleLowMemory()
+{
+    if (!m_ewkContext) {
+        return;
+    }
+
+    //ewk_context_cache_clear(m_ewkContext);
+    //ewk_context_notify_low_memory(m_ewkContext);
+}
+
+ContextManagerPtr createEwkContextManager(
+        std::string& tizenAppId,
+        Ewk_Context* ewkContext,
+        ViewModule::IViewModulePtr viewModule)
+{
+    return ContextManagerPtr(new EwkContextManager(tizenAppId, ewkContext, viewModule));
+}
+
+}
+
diff --git a/src/api_new/ewk_context_manager.h b/src/api_new/ewk_context_manager.h
new file mode 100644 (file)
index 0000000..7ef9dcd
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    ewk_context_manager.h
+ * @author  Yunchan Cho (yunchan.cho@samsung.com)
+ * @version 0.1
+ * @brief   Declaration of EwkContextManager class.
+ *          This file handles operation regarding Ewk_Context.
+ */
+
+#ifndef EWK_CONTEXT_MANAGER_H
+#define EWK_CONTEXT_MANAGER_H
+
+#include<abstract_context_manager.h>
+
+namespace WRT {
+
+class EwkContextManager : public AbstractContextManager {
+    public:
+        EwkContextManager(
+            const std::string& tizenAppId,
+            Ewk_Context* ewkContext,
+            ViewModule::IViewModulePtr viewModule);
+        Ewk_Context * getEwkContext() const;
+        void handleLowMemory();
+        ~EwkContextManager();
+
+    private:
+        bool initialize();
+        void destroy();
+        void setCallbacks();
+        void unsetCallbacks();
+
+        // ewk context callback functions
+        static void messageFromInjectedBundleCallback(
+                const char* name,
+                const char* body,
+                char** returnData,
+                void* clientInfo);
+        static void didStartDownloadCallback(const char* downloadUrl, void* data);
+        static void vibrationClientStartCallback(uint64_t time, void* data);
+        static void vibrationClientStopCallback(void* data);
+
+        // members
+        bool m_initialized;
+        bool m_isInternalContext;
+};
+
+}
+
+#endif // EWK_CONTEXT_MANAGER_H
index a032f26..b7d1726 100644 (file)
 #define RUNNABLE_WIDGET_OBJECT_INTERFACE_H_
 
 #include <dpl/wrt-dao-ro/wrt_db_types.h>
-#include <dpl/fast_delegate.h>
-#include <memory>
-#include <Evas.h>
-#include <widget_model.h>
-
+#include <ewk_context.h>
 #include <dpl/exception.h>
+#include <user_delegates.h>
 
 namespace WRT {
 
-typedef DPL::FastDelegate0<void> ProgressFinishCB;
-typedef DPL::FastDelegate1<Evas_Object*, void> LoadStartCB;
-typedef DPL::FastDelegate1<Evas_Object*, void> LoadFinishCB;
-typedef DPL::FastDelegate0<void> WebCrashCB;
-typedef DPL::FastDelegate2<Evas**, Evas_Object*, void> WindowCreateBeforeCB;
-typedef DPL::FastDelegate2<Evas_Object*, Evas_Object*, void> WindowCreateAfterCB;
-typedef DPL::FastDelegate1<Evas_Object*, void> WindowCloseCB;
-typedef DPL::FastDelegate0<void> WebkitExitCB;
-typedef DPL::FastDelegate1<bool, void> ResumeCB;
-typedef DPL::FastDelegate1<bool, void> SuspendCB;
-typedef DPL::FastDelegate1<bool, void> ResetCB;
-typedef DPL::FastDelegate1<Evas_Object*, void> BufferUnsetCB;
-typedef DPL::FastDelegate1<Evas_Object*, void> BufferSetCB;
-typedef DPL::FastDelegate1<bool, void> ToggleFullscreenCB;
-
-typedef struct UserDelegates {
-    ProgressFinishCB progressFinish;
-    LoadStartCB loadStart;
-    LoadFinishCB loadFinish;
-    WebCrashCB webCrash;
-    WindowCreateBeforeCB windowCreateBefore;
-    WindowCreateAfterCB windowCreateAfter;
-    WindowCloseCB windowClose;
-    WebkitExitCB webkitExit;
-    ResumeCB resume;
-    SuspendCB suspend;
-    ResetCB reset;
-    BufferUnsetCB bufferUnset;
-    BufferSetCB bufferSet;
-    ToggleFullscreenCB toggleFullscreen;
-} UserDelegates;
-
-typedef std::shared_ptr<UserDelegates> UserDelegatesPtr;
-typedef std::shared_ptr<WidgetModel> WidgetModelPtr;
-
 /**
  * @brief The IRunnableWidgetObject class Runnable object interface
  *
@@ -100,8 +62,9 @@ typedef std::shared_ptr<WidgetModel> WidgetModelPtr;
  *    \-------------(HIDDEN)
  *
  */
-class IRunnableWidgetObject {
-public:
+class IRunnableWidgetObject
+{
+  public:
     // IRunnableWidgetObject base exception
     DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
 
@@ -121,7 +84,8 @@ public:
      * @param callbacks passed to viewLogic
      */
     virtual bool PrepareView(const std::string &startUrl,
-                             Evas_Object *window) = 0;
+                             Evas_Object *window,
+                             Ewk_Context* ewkContext = NULL) = 0;
     /**
      * Shows widget asynchronously. Callback will be called when
      * webkit generates website.
@@ -168,12 +132,10 @@ public:
      */
     virtual void FireJavascriptEvent(int event, void* data) = 0;
 
-
-    virtual ~IRunnableWidgetObject() {};
+    virtual ~IRunnableWidgetObject() {}
 };
 
 typedef std::shared_ptr<IRunnableWidgetObject> RunnableWidgetObjectPtr;
-
 }
 #endif /* RUNNABLE_WIDGET_OBJECT_INTERFACE_H_ */
 
index 029a0fe..bc1c669 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <runnable_widget_object.h>
 #include <privilege-control.h>
+#include <dpl/exception.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/utils/wrt_global_settings.h>
 #include <appcore-common.h>
 #include <runnable_widget_object_state.h>
 #include <wrt_ocsp_api.h>
 #include <popup-runner/PopupInvoker.h>
+#include "ewk_context_manager.h"
 
 namespace { //Anonymous
-
-const wchar_t* BACKGROUND_ENABLED = L"background_enabled" ;
-
 const std::string ACCESS_DENIED = _("IDS_BR_POP_ACCESS_DENIED");
 const std::string ALREADY_RUNNING = _("IDS_BR_POP_ALREADY_RUNNING");
 const std::string INVALID_LOCALE = _("IDS_IM_POP_INVALID_WIDGET_LOCALE");
 const std::string STILL_AUTHORIZING = _("IDS_IM_POP_AUTHORIZING_ING_ATNT");
 const unsigned int UID_ROOT = 0;
-
 } // namespace anonymous
 
 namespace WRT {
-
-RunnableWidgetObject::RunnableWidgetObject(WidgetModelPtr &model, Ewk_Context* context) :
+RunnableWidgetObject::RunnableWidgetObject(WidgetModelPtr &model) :
         m_widgetModel(model),
         m_view(ViewModule::createView()),
-        m_ewkContext(context)
+        m_contextManagerFactoryMethod(makeContextManagerFactoryMethod<EwkContextManager>())
 {
     //set initial state of runnable object
-    m_guardstate = std::shared_ptr<State::RunnableWidgetObjectState>(new State::InitialState(*this));
+    m_guardstate = std::shared_ptr<State::RunnableWidgetObjectState>(
+            new State::InitialState(*this));
     // If current uid is 'root', change privilege to apps
     if (UID_ROOT == getuid()) {
         // Set privilege by tizen id
         // this code prevent that widget launch with "root" permission,
         // when developers launch by command in the shell
-        set_privilege(DPL::ToUTF8String(m_widgetModel->TizenId).c_str());
+
+        set_app_privilege(
+                DPL::ToUTF8String(m_widgetModel->TizenId).c_str(),
+                m_widgetModel->Type.Get().getApptypeToString().c_str(),
+                DPL::ToUTF8String(m_widgetModel->InstallPath.Get()).c_str()
+                );
     }
 }
 
@@ -82,11 +85,10 @@ bool RunnableWidgetObject::CheckBeforeLaunch()
 
     wrt_ocsp_widget_verification_status_t response;
     if (m_widgetModel->Type.Get().appType == WrtDB::APP_TYPE_WAC20) {
-
         wrt_ocsp_initialize();
-        wrt_ocsp_verify_widget(WrtDB::WidgetDAOReadOnly::getHandle(m_widgetModel->TizenId), &response);
+        wrt_ocsp_verify_widget(WrtDB::WidgetDAOReadOnly::getHandle(
+                                   m_widgetModel->TizenId), &response);
         wrt_ocsp_shutdown();
-
     } else {
         response = WRT_OCSP_WIDGET_VERIFICATION_STATUS_GOOD;
     }
@@ -108,17 +110,39 @@ bool RunnableWidgetObject::CheckBeforeLaunch()
 }
 
 bool RunnableWidgetObject::PrepareView(const std::string &startUrl,
-        Evas_Object *window)
+        Evas_Object *window, Ewk_Context* ewkContext)
 {
     State::StateChange change = m_guardstate->allowPrepareView();
-    Assert(window);
+    if (!window) {
+        return false;
+    }
+
+    std::string appId = DPL::ToUTF8String(m_widgetModel->TizenId);
+    Try {
+        if(!m_ewkContextManager) {
+            m_ewkContextManager = m_contextManagerFactoryMethod(appId, ewkContext, m_view);
+        } else {
+            if (ewkContext &&
+                    ewkContext != m_ewkContextManager->getEwkContext())
+            {
+                m_ewkContextManager = m_contextManagerFactoryMethod(appId, ewkContext, m_view);
+            }
+        }
+    } Catch (DPL::Exception) {
+        LogError("Internal Error during create or initialize Ewk Context");
+        return false;
+    }
 
     ADD_PROFILING_POINT("view_logic_init", "start");
-    if(!m_view->createWebView(m_ewkContext, window))
-    {
+    Ewk_Context* context = m_ewkContextManager->getEwkContext();
+
+    // plugin init
+    PluginModuleSupport::init(context, DPL::ToUTF8String(m_widgetModel->TizenId));
+
+    // view init
+    if(!m_view->createWebView(context, window)) {
         return false;
     }
-    m_view->initialize();
     m_view->prepareView(m_widgetModel.get(), startUrl);
     ADD_PROFILING_POINT("view_logic_init", "stop");
 
@@ -135,47 +159,20 @@ void RunnableWidgetObject::Show()
     change.commit();
 }
 
-void RunnableWidgetObject::Hide() {
+void RunnableWidgetObject::Hide()
+{
     State::StateChange change = m_guardstate->allowHide();
 
     m_view->hideWidget();
-    m_view->destroyWebView();
 
     change.commit();
 }
 
-void RunnableWidgetObject::Suspend() {
+void RunnableWidgetObject::Suspend()
+{
     LogDebug("Suspending widget");
     State::StateChange change = m_guardstate->allowSuspend();
-    Assert(m_widgetModel);
-
-    bool suspendWebkit = true;
-
-    if( m_widgetModel->SettingList.Get().getBackgroundSupport()
-        == BackgroundSupport_Enable ) {
-        //skip suspendWidget
-        LogDebug("Background enabled, skipping suspend");
-        suspendWebkit = false;
-    }
-#ifndef DEPRECATED_SETTING_STRING
-    else {
-        WrtDB::WidgetDAOReadOnly dao(m_widgetModel->TizenId);
-        WrtDB::PropertyDAOReadOnly::WidgetPropertyValue bgEnableValue =
-            dao.getPropertyValue(DPL::String(BACKGROUND_ENABLED));
-
-        if(!bgEnableValue.IsNull() && !bgEnableValue->compare(L"true")) {
-            //skip suspendWidget
-            LogDebug("Background enabled, skipping suspend");
-            suspendWebkit = false;
-        }
-    }
-#endif
-
-    m_view->changeViewVisibility(false);
-    if(suspendWebkit) //if widget has background page suspending wk will be skipped
-    {
-        m_view->suspendWidget();
-    }
+    m_view->suspendWidget();
 
     change.commit();
 }
@@ -203,7 +200,8 @@ void RunnableWidgetObject::ReloadStartPage()
     m_view->reloadStartPage();
 }
 
-Evas_Object* RunnableWidgetObject::GetCurrentWebview() {
+Evas_Object* RunnableWidgetObject::GetCurrentWebview()
+{
     State::StateChange change = m_guardstate->allowGetCurrentWebview();
 
     Evas_Object* cww = m_view->getCurrentWebview();
@@ -212,13 +210,15 @@ Evas_Object* RunnableWidgetObject::GetCurrentWebview() {
     return cww;
 }
 
-void RunnableWidgetObject::SetUserDelegates(const UserDelegatesPtr& cbs) {
+void RunnableWidgetObject::SetUserDelegates(const UserDelegatesPtr& cbs)
+{
     State::StateChange change = m_guardstate->allowSetUserDelegates();
     m_view->setUserCallbacks(cbs);
     change.commit();
 }
 
-void RunnableWidgetObject::Backward() {
+void RunnableWidgetObject::Backward()
+{
     State::StateChange change = m_guardstate->allowBackward();
     m_view->backward();
 
@@ -233,7 +233,20 @@ void RunnableWidgetObject::FireJavascriptEvent(int event, void* data)
     change.commit();
 }
 
-void RunnableWidgetObject::setNewState(std::shared_ptr<State::RunnableWidgetObjectState> sptr)
+void RunnableWidgetObject::setViewModule(ViewModule::IViewModulePtr ptr)
+{
+    LogDebug("Setting ViewModule");
+    m_view = ptr;
+}
+
+void RunnableWidgetObject::setContextManagerFactoryMethod(ContextManagerFactoryMethod method)
+{
+    LogDebug("Setting ContextManagerFactoryMethod");
+    m_contextManagerFactoryMethod = method;
+}
+
+void RunnableWidgetObject::setNewState(
+    std::shared_ptr<State::RunnableWidgetObjectState> sptr)
 {
     LogInfo("RunnableWidgetObject changes state to: " << sptr->toString());
     m_guardstate = sptr;
@@ -242,7 +255,13 @@ void RunnableWidgetObject::setNewState(std::shared_ptr<State::RunnableWidgetObje
 RunnableWidgetObject::~RunnableWidgetObject()
 {
     LogDebug("");
-    PluginModuleSupport::shutdown(m_ewkContext);
+    if(m_ewkContextManager)
+    {
+        PluginModuleSupport::shutdown(m_ewkContextManager->getEwkContext());
+    }
+    else
+    {
+        LogError("ewk context manager is null");
+    }
 }
-
 } /* namespace WRT */
index 281781c..3c1c047 100644 (file)
@@ -34,22 +34,23 @@ class StateChange;
 #include <string>
 #include <memory>
 
+#include <EWebKit2.h>
 #include <widget_model.h>
+#include <dpl/exception.h>
 #include <i_view_module.h>
+#include "ewk_context_manager.h"
 #include "i_runnable_widget_object.h"
-#include <EWebKit2.h>
 
 namespace WRT {
-
 class RunnableWidgetObject : public IRunnableWidgetObject
 {
 public:
-    RunnableWidgetObject(WidgetModelPtr &model, Ewk_Context* context);
+    RunnableWidgetObject(WidgetModelPtr &model);
     virtual ~RunnableWidgetObject();
 
     bool CheckBeforeLaunch();
     bool PrepareView(const std::string &startUrl,
-            Evas_Object *window);
+            Evas_Object *window, Ewk_Context* ewkContext = NULL);
     void Show(); //asynchronous function
     void Hide();
     void Suspend();
@@ -61,19 +62,22 @@ public:
     void Backward();
     void FireJavascriptEvent(int event, void* data);
 
-private:
+    void setViewModule(ViewModule::IViewModulePtr ptr);
+    void setContextManagerFactoryMethod(ContextManagerFactoryMethod method);
+  private:
 
     bool CheckWACTestCertififedWidget();
+    void setNewState(std::shared_ptr<WRT::State::RunnableWidgetObjectState> sptr);
 
     WidgetModelPtr m_widgetModel;
     ViewModule::IViewModulePtr m_view;
-    Ewk_Context* m_ewkContext;
-    void setNewState(std::shared_ptr<WRT::State::RunnableWidgetObjectState> sptr);
-
     std::shared_ptr<State::RunnableWidgetObjectState> m_guardstate;
+    ContextManagerPtr m_ewkContextManager;
+
+    //factor method to be used for creation of context manager when needed
+    ContextManagerFactoryMethod m_contextManagerFactoryMethod;
 
     friend class State::StateChange;
 };
-
 } /* namespace WRT */
 #endif /* RUNNABLE_WIDGET_OBJECT_H_ */
index bb1990f..6eeedba 100644 (file)
 
 namespace WRT {
 namespace State {
-
 const StateChange StateChange::NoChange = StateChange();
 
 StateChange::StateChange()
-{
-}
+{}
 
-StateChange::StateChange(RunnableWidgetObjectStatePtr sptr)
-    : m_sptr(sptr)
-{
-}
+StateChange::StateChange(RunnableWidgetObjectStatePtr sptr) :
+    m_sptr(sptr)
+{}
 
 void StateChange::commit()
 {
-    if(m_sptr)
-    {
+    if (m_sptr) {
         m_sptr->getObject().setNewState(m_sptr);
     }
 }
 
-RunnableWidgetObjectState::RunnableWidgetObjectState(RunnableWidgetObject & object)
-    : m_object(object)
-{
-}
+RunnableWidgetObjectState::RunnableWidgetObjectState(
+    RunnableWidgetObject & object) :
+    m_object(object)
+{}
 
 RunnableWidgetObjectState::~RunnableWidgetObjectState()
-{
-}
+{}
 
 RunnableWidgetObject & RunnableWidgetObjectState::getObject() const
 {
@@ -138,9 +133,9 @@ StateChange RunnableWidgetObjectState::allowFireJavascriptEvent()
              "FireJavascriptEvent cannot be called in current state ");
 }
 
-InitialState::InitialState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+InitialState::InitialState(RunnableWidgetObject & object) :
+    RunnableWidgetObjectState(object)
+{}
 
 std::string InitialState::toString() const
 {
@@ -160,17 +155,19 @@ StateChange InitialState::allowHide()
 
 StateChange InitialState::allowGetCurrentWebview()
 {
-    ThrowMsg(IRunnableWidgetObject::MethodInvocationForbidden,
-             "Cannot call GetCurrentWebview before RunnableWidgetObject initialization");
+    ThrowMsg(
+        IRunnableWidgetObject::MethodInvocationForbidden,
+        "Cannot call GetCurrentWebview before RunnableWidgetObject initialization");
 }
 
-PreparedState::PreparedState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+PreparedState::PreparedState(RunnableWidgetObject & object) :
+    RunnableWidgetObjectState(object)
+{}
 
 StateChange PreparedState::allowCheckBeforeLaunch()
 {
-    return StateChange(RunnableWidgetObjectStatePtr(new SecurityCheckedState(m_object)));
+    return StateChange(RunnableWidgetObjectStatePtr(new SecurityCheckedState(
+                                                        m_object)));
 }
 
 std::string PreparedState::toString() const
@@ -178,9 +175,9 @@ std::string PreparedState::toString() const
     return "PREPARED";
 }
 
-SecurityCheckedState::SecurityCheckedState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+SecurityCheckedState::SecurityCheckedState(RunnableWidgetObject & object) :
+    RunnableWidgetObjectState(object)
+{}
 
 std::string SecurityCheckedState::toString() const
 {
@@ -197,9 +194,9 @@ StateChange SecurityCheckedState::allowSetUserDelegates()
     return StateChange::NoChange;
 }
 
-ShowedState::ShowedState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+ShowedState::ShowedState(RunnableWidgetObject & object) :
+    RunnableWidgetObjectState(object)
+{}
 
 std::string ShowedState::toString() const
 {
@@ -236,9 +233,9 @@ StateChange ShowedState::allowFireJavascriptEvent()
     return StateChange::NoChange;
 }
 
-SuspendedState::SuspendedState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+SuspendedState::SuspendedState(RunnableWidgetObject & object) :
+    RunnableWidgetObjectState(object)
+{}
 
 std::string SuspendedState::toString() const
 {
@@ -255,9 +252,9 @@ StateChange SuspendedState::allowReset()
     return StateChange(RunnableWidgetObjectStatePtr(new ShowedState(m_object)));
 }
 
-HiddenState::HiddenState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+HiddenState::HiddenState(RunnableWidgetObject & object) :
+    RunnableWidgetObjectState(object)
+{}
 
 std::string HiddenState::toString() const
 {
@@ -269,6 +266,5 @@ StateChange HiddenState::allowHide()
     ThrowMsg(IRunnableWidgetObject::MethodInvocationForbidden,
              "Hide cannot be called in current state" << toString());
 }
-
 }
 }
index 3a246d3..fe9ea13 100644 (file)
@@ -29,7 +29,6 @@ class RunnableWidgetObject;
 namespace State {
 class RunnableWidgetObjectState;
 }
-
 }
 
 #include <dpl/exception.h>
@@ -38,7 +37,6 @@ class RunnableWidgetObjectState;
 
 namespace WRT {
 namespace State {
-
 typedef std::shared_ptr<RunnableWidgetObjectState> RunnableWidgetObjectStatePtr;
 
 /**
@@ -48,7 +46,7 @@ typedef std::shared_ptr<RunnableWidgetObjectState> RunnableWidgetObjectStatePtr;
  */
 class StateChange
 {
-public:
+  public:
     static const StateChange NoChange;
 
     StateChange();
@@ -58,7 +56,8 @@ public:
      * @brief commit actually performs change of state
      */
     void commit();
-private:
+
+  private:
     RunnableWidgetObjectStatePtr m_sptr;
 };
 
@@ -73,7 +72,7 @@ private:
  */
 class RunnableWidgetObjectState
 {
-public:
+  public:
     explicit RunnableWidgetObjectState(RunnableWidgetObject & object);
     virtual ~RunnableWidgetObjectState();
 
@@ -94,7 +93,7 @@ public:
     virtual std::string toString() const = 0;
     virtual RunnableWidgetObject & getObject() const;
 
-protected:
+  protected:
     RunnableWidgetObject & m_object;
 };
 
@@ -103,7 +102,7 @@ protected:
  */
 class InitialState : public RunnableWidgetObjectState
 {
-public:
+  public:
     explicit InitialState(RunnableWidgetObject & object);
     std::string toString() const;
 
@@ -117,7 +116,7 @@ public:
  */
 class PreparedState : public RunnableWidgetObjectState
 {
-public:
+  public:
     explicit PreparedState(RunnableWidgetObject & object);
     std::string toString() const;
 
@@ -129,7 +128,7 @@ public:
  */
 class SecurityCheckedState : public RunnableWidgetObjectState
 {
-public:
+  public:
     explicit SecurityCheckedState(RunnableWidgetObject & object);
     std::string toString() const;
 
@@ -142,7 +141,7 @@ public:
  */
 class ShowedState : public RunnableWidgetObjectState
 {
-public:
+  public:
     explicit ShowedState(RunnableWidgetObject & object);
     std::string toString() const;
 
@@ -159,7 +158,7 @@ public:
  */
 class SuspendedState : public RunnableWidgetObjectState
 {
-public:
+  public:
     explicit SuspendedState(RunnableWidgetObject & object);
     std::string toString() const;
 
@@ -172,13 +171,12 @@ public:
  */
 class HiddenState : public RunnableWidgetObjectState
 {
-public:
+  public:
     explicit HiddenState(RunnableWidgetObject & object);
     std::string toString() const;
 
     StateChange allowHide();
 };
-
 }
 }
 
diff --git a/src/api_new/user_delegates.h b/src/api_new/user_delegates.h
new file mode 100644 (file)
index 0000000..79e73ec
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file        user_delegates.h
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       user delegates
+ */
+#ifndef USER_DELEGATES_H
+#define USER_DELEGATES_H
+
+#include <dpl/fast_delegate.h>
+#include <widget_model.h>
+#include <memory>
+#include <Evas.h>
+
+namespace WRT {
+typedef DPL::FastDelegate0<void> ProgressFinishCB;
+typedef DPL::FastDelegate1<Evas_Object*, void> LoadStartCB;
+typedef DPL::FastDelegate1<Evas_Object*, void> LoadFinishCB;
+typedef DPL::FastDelegate0<void> WebCrashCB;
+typedef DPL::FastDelegate2<Evas**, Evas_Object*, void> WindowCreateBeforeCB;
+typedef DPL::FastDelegate2<Evas_Object*, Evas_Object*,
+                           void> WindowCreateAfterCB;
+typedef DPL::FastDelegate1<Evas_Object*, void> WindowCloseCB;
+typedef DPL::FastDelegate0<void> WebkitExitCB;
+typedef DPL::FastDelegate1<bool, void> ResumeCB;
+typedef DPL::FastDelegate1<bool, void> SuspendCB;
+typedef DPL::FastDelegate1<bool, void> ResetCB;
+typedef DPL::FastDelegate1<Evas_Object*, void> BufferUnsetCB;
+typedef DPL::FastDelegate1<Evas_Object*, void> BufferSetCB;
+typedef DPL::FastDelegate1<bool, void> ToggleFullscreenCB;
+
+struct UserDelegates {
+    ProgressFinishCB progressFinish;
+    LoadStartCB loadStart;
+    LoadFinishCB loadFinish;
+    WebCrashCB webCrash;
+    WindowCreateBeforeCB windowCreateBefore;
+    WindowCreateAfterCB windowCreateAfter;
+    WindowCloseCB windowClose;
+    WebkitExitCB webkitExit;
+    ResumeCB resume;
+    SuspendCB suspend;
+    ResetCB reset;
+    BufferUnsetCB bufferUnset;
+    BufferSetCB bufferSet;
+    ToggleFullscreenCB toggleFullscreen;
+};
+
+typedef std::shared_ptr<UserDelegates> UserDelegatesPtr;
+typedef std::shared_ptr<WidgetModel> WidgetModelPtr;
+}
+
+#endif // USER_DELEGATES_H
index 755b0ff..c18bc88 100644 (file)
@@ -36,8 +36,7 @@ struct WrtLaunchData {
     WrtLaunchData() :
         wrtClientContext(NULL),
         sdkDebugData(NULL)
-    {
-    }
+    {}
 };
 
 struct SDKDebugData
@@ -50,8 +49,7 @@ struct SDKDebugData
         pid(NULL),
         portnum(-1),
         debugMode(false)
-    {
-    }
+    {}
 
     SDKDebugData(unsigned long *pidNum,
                  int portNum,
@@ -59,8 +57,7 @@ struct SDKDebugData
         pid(pidNum),
         portnum(portNum),
         debugMode(currentDebugMode)
-    {
-    }
+    {}
 };
 
 #endif // WRT_LAUNCH_USER_DATA_H_
index 82e0edb..79aae9e 100644 (file)
@@ -25,8 +25,7 @@
 
 #include <appcore-efl.h>
 
-namespace LocalizationSetting{
-
+namespace LocalizationSetting {
 void SetLanguageChangedCallback(LanguageChangedCallback cb, void *data)
 {
     LogDebug("Set language changed callback");
index 7f5dc34..adcca0a 100644 (file)
 #define LOCALIZATION_SETTING_H_
 
 namespace LocalizationSetting {
-
 typedef int (*LanguageChangedCallback)(void *data);
 
 void SetLanguageChangedCallback(LanguageChangedCallback cb, void *data);
-
 } //LocalizationSetting
 
 #endif // ifndef LOCALIZATION_SETTING_H_
index 9367b92..d2862cc 100644 (file)
@@ -31,8 +31,7 @@ IMPLEMENT_SINGLETON(MainThread)
 
 using namespace WrtDB;
 
-MainThread::MainThread() : m_attached(false) {
-}
+MainThread::MainThread() : m_attached(false) {}
 
 MainThread::~MainThread()
 {
index ad95089..df00289 100644 (file)
@@ -24,7 +24,8 @@
 
 #include <dpl/singleton.h>
 
-class MainThread {
+class MainThread
+{
   public:
     void AttachDatabases();
     void DetachDatabases();
index d92197c..2fee42c 100644 (file)
@@ -21,7 +21,8 @@
 /**
  * @file       widget_data_types.cpp
  * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @author     Tomasz Iwanek (t.iwanek@samsung.com) (implementation moved to cpp)
+ * @author     Tomasz Iwanek (t.iwanek@samsung.com) (implementation moved to
+ * cpp)
  * @version    0.1
  * @brief
  */
 #include <dpl/foreach.h>
 
 WidgetAccessList::WidgetAccessList() : m_isAccessAll(false)
-{
-}
+{}
 
-WidgetAccessList::WidgetAccessList(const WrtDB::WidgetAccessInfoList &widgetAccessInfoList) :
+WidgetAccessList::WidgetAccessList(
+    const WrtDB::WidgetAccessInfoList &widgetAccessInfoList) :
     m_isAccessAll(false)
 {
     FOREACH(it, widgetAccessInfoList)
@@ -98,8 +99,7 @@ WidgetSettingList::WidgetSettingList() :
     m_ContextMenu(ContextMenu_Enable),
     m_Encryption(Encryption_Disable),
     m_BackgroundSupport(BackgroundSupport_Disable)
-{
-}
+{}
 
 WidgetSettingList::WidgetSettingList(WidgetSettings &widgetSettings)
 {
@@ -134,43 +134,46 @@ WidgetSettingList::WidgetSettingList(WidgetSettings &widgetSettings)
                 m_IndicatorPresence = Indicator_Disable;
             } else {
                 LogError("Invalid indicator presence value!! [" <<
-                    value << "]");
+                         value << "]");
                 m_IndicatorPresence = Indicator_Enable;
             }
         } else if (name == SETTING_NAME_BACKBUTTON_PRESENCE) {
             if (value == SETTING_VALUE_BACKBUTTON_PRESENCE_ENALBE) {
                 m_BackButtonPresence = BackButton_Enable;
             } else if (value ==
-                            SETTING_VALUE_BACKBUTTON_PRESENCE_DISABLE) {
+                       SETTING_VALUE_BACKBUTTON_PRESENCE_DISABLE)
+            {
                 m_BackButtonPresence = BackButton_Disable;
             } else {
                 LogError("Invalid backbutton presence value!! [" <<
-                    value << "]");
+                         value << "]");
                 m_BackButtonPresence = BackButton_Disable;
             }
-        } else if ( name == SETTING_NAME_CONTEXT_MENU
+        } else if (name == SETTING_NAME_CONTEXT_MENU
 #ifndef DEPRECATED_SETTING_STRING
-                    || name == SETTING_NAME_CONTEXTMENU
+                   || name == SETTING_NAME_CONTEXTMENU
 #endif
-                  ) {
+                   )
+        {
             if (value == SETTING_VALUE_ENABLE) {
                 m_ContextMenu = ContextMenu_Enable;
             } else if (value == SETTING_VALUE_DISABLE) {
                 m_ContextMenu = ContextMenu_Disable;
             } else {
                 LogError("Invalid contextmenu value!! [" <<
-                    value << "]");
+                         value << "]");
                 m_ContextMenu = ContextMenu_Enable;
             }
         } else if (name == SETTING_NAME_ENCRYPTION) {
             if (value == SETTING_VALUE_ENCRYPTION_ENABLE) {
                 m_Encryption = Encryption_Enable;
             } else if (value ==
-                            SETTING_VALUE_ENCRYPTION_DISABLE) {
+                       SETTING_VALUE_ENCRYPTION_DISABLE)
+            {
                 m_Encryption = Encryption_Disable;
             } else {
                 LogError("Invalid encryption value!! [" <<
-                    value << "]");
+                         value << "]");
                 m_Encryption = Encryption_Disable;
             }
         } else if (name == SETTING_NAME_BACKGROUND_SUPPORT) {
@@ -180,7 +183,7 @@ WidgetSettingList::WidgetSettingList(WidgetSettings &widgetSettings)
                 m_BackgroundSupport = BackgroundSupport_Disable;
             } else {
                 LogError("Invalid background-support value!! [" <<
-                    value << "]");
+                         value << "]");
                 m_BackgroundSupport = BackgroundSupport_Disable;
             }
         } else if (name == SETTING_NAME_USER_AGENT) {
@@ -210,7 +213,8 @@ WidgetSettingIndicatorPresence WidgetSettingList::getIndicatorPresence() const
     return m_IndicatorPresence;
 }
 
-WidgetSettingBackButtonPresence WidgetSettingList::getBackButtonPresence() const
+WidgetSettingBackButtonPresence WidgetSettingList::getBackButtonPresence()
+const
 {
     return m_BackButtonPresence;
 }
@@ -246,10 +250,10 @@ std::string WidgetSettingList::getUserAgent() const
 bool WidgetSettingList::operator ==(const WidgetSettingList& other) const
 {
     return m_RotationLock == other.m_RotationLock &&
-        m_IndicatorPresence == other.m_IndicatorPresence &&
-        m_BackButtonPresence == other.m_BackButtonPresence &&
-        m_ContextMenu == other.m_ContextMenu &&
-        m_Encryption == other.m_Encryption &&
-        m_BackgroundSupport == other.m_BackgroundSupport &&
-        m_UserAgent == other.m_UserAgent;
+           m_IndicatorPresence == other.m_IndicatorPresence &&
+           m_BackButtonPresence == other.m_BackButtonPresence &&
+           m_ContextMenu == other.m_ContextMenu &&
+           m_Encryption == other.m_Encryption &&
+           m_BackgroundSupport == other.m_BackgroundSupport &&
+           m_UserAgent == other.m_UserAgent;
 }
index a3fcdf4..9d2e73a 100644 (file)
@@ -115,7 +115,7 @@ static const DPL::String SETTING_VALUE_ENABLE =
     L"enable";
 static const DPL::String SETTING_VALUE_DISABLE =
     L"disable";
-static const DPL::String SETTING_NAME_ENCRYPTION=
+static const DPL::String SETTING_NAME_ENCRYPTION =
     L"encryption";
 static const DPL::String SETTING_VALUE_SCREEN_ORIENTATION_PORTRAIT =
     L"portrait";
index 6c121d9..3a040a6 100644 (file)
@@ -27,9 +27,7 @@
 // to apply widget default locales instead of calling localizeWidgetModel()
 #include <dpl/localization/LanguageTagsProvider.h>
 
-
 namespace Domain {
-
 std::shared_ptr<WidgetModel> deserializeWidgetModel(const std::string& tizenId)
 {
     std::shared_ptr<WidgetModel> model;
@@ -40,9 +38,9 @@ std::shared_ptr<WidgetModel> deserializeWidgetModel(const std::string& tizenId)
 
         WrtDB::WidgetDAOReadOnly dao(dplTizenId);
         DPL::Optional<DPL::String> defloc = model->defaultlocale.Get();
-        if(!defloc.IsNull())
-        {
-            LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc);
+        if (!defloc.IsNull()) {
+            LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
+                *defloc);
         }
 
         WrtDB::WidgetAccessInfoList widgetAccessInfoList;
@@ -65,6 +63,5 @@ std::shared_ptr<WidgetModel> deserializeWidgetModel(const std::string& tizenId)
     }
     return model;
 }
-
 } //Namespace Domain
 
index 83eb41f..21a8126 100644 (file)
 #include <dpl/wrt-dao-ro/wrt_db_types.h>
 
 namespace Domain {
-
 /**
  * @brief Creates widget model associated with selected
  * @param[in] tizenId
  * @retval WidgetModel
  */
 std::shared_ptr<WidgetModel> deserializeWidgetModel(const std::string& tizenId);
-
 } //Namespace Domain
 
 #endif // ifndef WRT_ENGINE_SRC_DOMAIN_WIDGET_DESERIALIZE_MODEL_H_
index 625899e..b378da4 100644 (file)
@@ -30,7 +30,7 @@
 
 using namespace WrtDB;
 
-template <typename RetType, RetType (WidgetDAOReadOnly::*extFun)() const >
+template <typename RetType, RetType(WidgetDAOReadOnly::*extFun) () const >
 struct BindToWidgetDAO :
     DPL::Event::BindToDAO<WidgetModel,
                           RetType,
@@ -38,8 +38,7 @@ struct BindToWidgetDAO :
                           WidgetDAOReadOnly,
                           &WidgetModel::getTizenId,
                           extFun>
-{
-};
+{};
 
 template <typename RetType, RetType(*extFun) (DPL::String)>
 struct BindToWidgetDAOStatic :
@@ -48,13 +47,18 @@ struct BindToWidgetDAOStatic :
                                  DPL::String,
                                  &WidgetModel::getTizenId,
                                  extFun>
-{
-};
+{};
 
 WidgetModel::WidgetModel(const std::string &tizenId) :
     TizenId(DPL::FromASCIIString(tizenId)),
+    TzPkgId(this, &BindToWidgetDAO<WrtDB::TizenPkgId,
+                                   &WidgetDAOReadOnly::getTizenPkgId>::Get),
     Type(this, &BindToWidgetDAO<WidgetType,
-         &WidgetDAOReadOnly::getWidgetType>::Get),
+                                &WidgetDAOReadOnly::getWidgetType>::Get),
+    CspPolicy(this, &BindToWidgetDAO<DPL::OptionalString,
+                                     &WidgetDAOReadOnly::getCspPolicy>::Get),
+    CspReportOnlyPolicy(this, &BindToWidgetDAO<DPL::OptionalString,
+                        &WidgetDAOReadOnly::getCspPolicyReportOnly>::Get),
     ActualSize(this),
     PreferredSize(this,
                   &BindToWidgetDAO<WidgetSize,
@@ -103,15 +107,16 @@ WidgetModel::WidgetModel(const std::string &tizenId) :
         &BindToWidgetDAO<WindowModeList,
                          &WidgetDAOReadOnly::getWindowModes>::Get),
     //localized, so not binded
-//    AccessNetwork(this, false),
-//    WarpDefinitionEmpty(this),
+    //    AccessNetwork(this, false),
+    //    WarpDefinitionEmpty(this),
     BackSupported(
         this,
         //TODO this type has to be here now, as Property constructor is wrongly
         //chosen
         (DPL::Event::Property<bool,
-                       DPL::Event::PropertyReadOnly,
-                       DPL::Event::PropertyStorageDynamicCached>::ReadDelegateType) &
+                              DPL::Event::PropertyReadOnly,
+                              DPL::Event::PropertyStorageDynamicCached>::
+             ReadDelegateType) &
         BindToWidgetDAO<bool, &WidgetDAOReadOnly::getBackSupported>::Get),
     AccessList(this),
     IsTestWidget(
@@ -119,14 +124,14 @@ WidgetModel::WidgetModel(const std::string &tizenId) :
         //TODO this type has to be here now, as Property constructor is wrongly
         //chosen
         (DPL::Event::Property<bool,
-                       DPL::Event::PropertyReadOnly,
-                       DPL::Event::PropertyStorageDynamicCached>::ReadDelegateType) &
+                              DPL::Event::PropertyReadOnly,
+                              DPL::Event::PropertyStorageDynamicCached>::
+             ReadDelegateType) &
         BindToWidgetDAO<bool, &WidgetDAOReadOnly::isTestWidget>::Get),
 
     SettingList(this),
     AppServiceList(this)
-{
-}
+{}
 
 DPL::String WidgetModel::getTizenId() const
 {
index 51ff9fc..496383d 100644 (file)
@@ -48,8 +48,18 @@ class WidgetModel : public DPL::Event::Model
 
     /**
      * @brief Tizen id
+     *
+     *  ex> "TizenIDabc.appname"
+     *
+     *  - TizenId / AppId : "TizenIDabc.appname"
+     *  - TzPkgId         : "TizenIDabc"
+     *  - App name        : "appname"
+     *
      */
     DPL::String TizenId;
+    DPL::Event::Property<WrtDB::TizenPkgId,
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached> TzPkgId;
 
     /**
      * @brief Widget type
@@ -57,8 +67,23 @@ class WidgetModel : public DPL::Event::Model
      * Note: This is a readonly property
      */
     DPL::Event::Property<WrtDB::WidgetType,
-    DPL::Event::PropertyReadOnly,
-    DPL::Event::PropertyStorageDynamicCached> Type;
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached> Type;
+
+    /**
+     * @brief Config file based csp policy
+     */
+    DPL::Event::Property<DPL::OptionalString,
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached> CspPolicy;
+
+    /**
+     * @brief Config file based csp policy - report only
+     */
+    DPL::Event::Property<DPL::OptionalString,
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached>
+    CspReportOnlyPolicy;
 
     /**
      * @brief Current widget actual size
@@ -69,8 +94,9 @@ class WidgetModel : public DPL::Event::Model
      * @brief Current widget preferred size
      */
     DPL::Event::Property<WidgetSize,
-                  DPL::Event::PropertyReadOnly,
-                  DPL::Event::PropertyStorageDynamicCached> PreferredSize;
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached>
+    PreferredSize;
 
     /**
      * @brief Start URL for widget
@@ -96,29 +122,32 @@ class WidgetModel : public DPL::Event::Model
      * Gets path in which files of widget are being kept
      */
     DPL::Event::Property<DPL::String,
-                  DPL::Event::PropertyReadOnly,
-                  DPL::Event::PropertyStorageDynamicCached> InstallPath;
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached> InstallPath;
 
     /**
      * @brief Path to widget's persistent storage.
      *
      * Gets path in which widget may store its persistent private data.
      */
-    DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> PersistentStoragePath;
+    DPL::Event::Property<DPL::String,
+                         DPL::Event::PropertyReadOnly> PersistentStoragePath;
 
     /**
      * @brief Path to widget's temporary storage.
      *
      * Gets path in which widget may store its temporary private data.
      */
-    DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> TemporaryStoragePath;
+    DPL::Event::Property<DPL::String,
+                         DPL::Event::PropertyReadOnly> TemporaryStoragePath;
 
     /**
      * @brief Widget defaultlocale
      */
     DPL::Event::Property<DPL::OptionalString,
-                  DPL::Event::PropertyReadOnly,
-                  DPL::Event::PropertyStorageDynamicCached> defaultlocale;
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached>
+    defaultlocale;
 
     /**
      * @brief Widget name
@@ -154,15 +183,15 @@ class WidgetModel : public DPL::Event::Model
      * @brief Widget splash image src
      */
     DPL::Event::Property<DPL::OptionalString,
-                  DPL::Event::PropertyReadOnly,
-                  DPL::Event::PropertyStorageDynamicCached> SplashImg;
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached> SplashImg;
 
     /**
      * @brief window mode
      */
     DPL::Event::Property<WrtDB::WindowModeList,
-                  DPL::Event::PropertyReadOnly,
-                  DPL::Event::PropertyStorageDynamic> WindowModes;
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamic> WindowModes;
 
     //    /**
     //     * @brief Value of network element.
@@ -179,8 +208,9 @@ class WidgetModel : public DPL::Event::Model
      * @brief Is back supported
      */
     DPL::Event::Property<bool,
-                  DPL::Event::PropertyReadOnly,
-                  DPL::Event::PropertyStorageDynamicCached> BackSupported;
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached>
+    BackSupported;
 
     /**
      * @brief Widget access list
@@ -191,9 +221,8 @@ class WidgetModel : public DPL::Event::Model
      * @brief Is this DeveloperWidget
      */
     DPL::Event::Property<bool,
-                  DPL::Event::PropertyReadOnly,
-                  DPL::Event::PropertyStorageDynamicCached> IsTestWidget;
-
+                         DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached> IsTestWidget;
 
     DPL::Event::Property<WidgetSettingList> SettingList;
 
index 600e5fa..80720a3 100644 (file)
@@ -30,7 +30,6 @@
 #include <js_overlay_types.h>
 
 namespace PluginModule {
-
 void init(int widgetHandle)
 {
     LogDebug("initializing plugins module");
@@ -102,5 +101,4 @@ void unloadFrame(JSGlobalContextRef context)
     LogDebug("unload frame from web page (context:" << context << ")");
     PluginLogicSingleton::Instance().unloadFrame(context);
 }
-
 } // PluginModule
index 0203ac7..cd0d85f 100644 (file)
 #include <js_overlay_types.h>
 
 extern "C" {
-    typedef struct OpaqueJSContext* JSGlobalContextRef;
+typedef struct OpaqueJSContext* JSGlobalContextRef;
 }
 
 namespace PluginModule {
-
 //forward declaration
 void init(int widgetHandle);
 void start(int widgetHandle,
index 0207711..cd94c0f 100644 (file)
@@ -32,6 +32,8 @@
 #include <dpl/foreach.h>
 #include <dpl/log/log.h>
 #include <dpl/mutex.h>
+#include <dpl/static_block.h>
+#include <dpl/assert.h>
 
 namespace {
 const int PROFILING_OUTPUT_DESCRIPTOR = 3;
@@ -55,23 +57,25 @@ struct PacketResult
         name(0),
         prefix(0),
         description(0)
-    {
-    }
+    {}
     PacketResult(unsigned long long t,
-            const char* n,
-            const char* p,
-            const char* d) :
+                 const char* n,
+                 const char* p,
+                 const char* d) :
         time(t),
         name(n),
         prefix(p),
         description(d)
-    {
-    }
+    {}
 
     void Print(FILE *filePtr)
     {
-        if (!prefix) { prefix = ""; }
-        if (!description) { description = ""; }
+        if (!prefix) {
+            prefix = "";
+        }
+        if (!description) {
+            description = "";
+        }
         fprintf(filePtr, "%s#%s#%llu#[%s]\n", prefix, name, time, description);
     }
 };
@@ -108,21 +112,16 @@ void sigUsrHandler(int /*num*/)
     dumpStatistic();
 }
 
-int initialize();
-
-const int i = initialize();
 DPL::Mutex* m_mutex = NULL;
 
-int initialize()
+void initialize()
 {
-    (void)i;
     m_mutex = new DPL::Mutex;
     results.reserve(64 * 1024);
     signal(SIGUSR1, &sigUsrHandler);
     signal(SIGUSR2, &sigUsrHandler);
     LogDebug("Initialized profiling");
     AddProfilingMeasurment("Profiling_Started");
-    return 1;
 }
 
 std::string GetFormattedTime()
@@ -134,24 +133,30 @@ std::string GetFormattedTime()
     localtime_r(&tv.tv_sec, &localNowTime);
 
     char format[64];
-    snprintf(format, sizeof(format), "%02i:%02i:%02i.%03i", localNowTime.tm_hour, localNowTime.tm_min, localNowTime.tm_sec, static_cast<int>(tv.tv_usec / 1000));
+    snprintf(format,
+             sizeof(format),
+             "%02i:%02i:%02i.%03i",
+             localNowTime.tm_hour,
+             localNowTime.tm_min,
+             localNowTime.tm_sec,
+             static_cast<int>(tv.tv_usec / 1000));
     return format;
 }
-
 } // namespace anonymous
 
 void AddStdoutProfilingMeasurment(const char* name, bool start)
 {
+    Assert(m_mutex != NULL);
     std::ostringstream output;
-    output << "[" << GetFormattedTime()  << "] [](): " << name << " ";
+    output << "[" << GetFormattedTime() << "] [](): " << name << " ";
     output << (start ? "profiling##start" : "profiling##stop");
     fprintf(stdout, "%s\n", output.str().c_str());
 }
 
 extern "C"
 void AddProfilingMeasurment(const char* name,
-        const char* prefix,
-        const char* description)
+                            const char* prefix,
+                            const char* description)
 {
     DPL::Mutex::ScopedLock lock(m_mutex);
     struct timeval value;
@@ -159,3 +164,9 @@ void AddProfilingMeasurment(const char* name,
     results.push_back(
         PacketResult(toULong(value), name, prefix, description));
 }
+
+STATIC_BLOCK
+{
+    initialize();
+}
+
index 64b909a..13ec532 100644 (file)
 #ifdef __cplusplus
 extern "C"
 void AddProfilingMeasurment(const char* name,
-        const char* prefix = 0,
-        const char* description = 0);
+                            const char* prefix = 0,
+                            const char* description = 0);
 #define ADD_PROFILING_POINT(name, ...) AddProfilingMeasurment(name, \
-                                                              ## __VA_ARGS__)
+                                                              ##__VA_ARGS__)
 #else //__cplusplus
 void AddProfilingMeasurment(const char* name,
-        const char* prefix,
-        const char* description);
+                            const char* prefix,
+                            const char* description);
 #define ADD_PROFILING_POINT(name, prefix, desc) AddProfilingMeasurment(name, \
                                                                        prefix, \
                                                                        desc)
index 84c5fb9..e20ece2 100755 (executable)
@@ -81,7 +81,7 @@ sub runWidget {
     chomp $line;
     if (my ($p) = $line =~ /^TEST-WIDGET-PID (\d+)/) {
         $pid = 0+$p;
-    } elsif ($line =~ /^launched$/) {
+    } elsif ($line =~ /launched$/) {
         print "launched detected $pid\n";
         kill 10, $pid;
         my $again = 1;
@@ -218,7 +218,7 @@ sub dropAndInstallAll {
         }
         my @out = `$WRT_CLIENT_QUERY`;
         for my $line (@out) {
-            if (my ($name, $trash, $tizenId) = $line =~ /^\s*\d+\s+(([^ ]| [^ ])+)\s+.*\s+([A-Za-z0-9]{10})$/) {
+            if (my ($name, $trash, $tizenId) = $line =~ /^\s*\d+\s+(([^ ]| [^ ])+)\s+.*\s+([A-Za-z0-9]{10}\.[^\s]+)\s*$/) {
                 print "    found $name (tizenId $tizenId)\n";
                 $widgetMap{$name} = $tizenId;
             }
old mode 100644 (file)
new mode 100755 (executable)
index 5b9bfc3..5eb7dcb
@@ -45,6 +45,7 @@ PKG_CHECK_MODULES(VIEW_COMMON_DEP
     dpl-wrt-dao-ro
     wrt-commons-auto-save-dao-rw
     wrt-commons-security-origin-dao
+    wrt-commons-certificate-dao
     wrt-popup-wrt-runner
     REQUIRED
 )
@@ -67,6 +68,7 @@ SET(VIEW_COMMON_SOURCES
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_uri_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_user_agent_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_vibration_support.cpp
+    ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_certificate_support.cpp
 )
 
 SET(VIEW_COMMON_INCLUDES
index 2bfa7fd..23f7fd1 100644 (file)
@@ -30,12 +30,10 @@ IMPLEMENT_SINGLETON(ApplicationData)
 ApplicationData::ApplicationData() :
     m_originBundle(NULL),
     m_encodedBundle(NULL)
-{
-}
+{}
 
 ApplicationData::~ApplicationData()
-{
-}
+{}
 
 bundle* ApplicationData::getBundle() const
 {
@@ -49,8 +47,7 @@ const char* ApplicationData::getEncodedBundle() const
 
 bool ApplicationData::setBundle(bundle *originBundle)
 {
-    if (!originBundle)
-    {
+    if (!originBundle) {
         LogError("Bundle is empty!");
         return false;
     }
@@ -64,8 +61,7 @@ bool ApplicationData::setBundle(bundle *originBundle)
 bool ApplicationData::setEncodedBundle(bundle* originBundle)
 {
     int len, ret;
-    if (!originBundle)
-    {
+    if (!originBundle) {
         LogError("Bundle is empty!");
         return false;
     }
@@ -73,8 +69,7 @@ bool ApplicationData::setEncodedBundle(bundle* originBundle)
     freeEncodedBundle();
 
     ret = bundle_encode(originBundle, &m_encodedBundle, &len);
-    if(ret == -1)
-    {
+    if (ret == -1) {
         LogError("Failed to encode bundle data");
         return false;
     }
@@ -85,13 +80,11 @@ bool ApplicationData::setEncodedBundle(bundle* originBundle)
 
 void ApplicationData::freeBundle()
 {
-    if (!m_originBundle)
-    {
+    if (!m_originBundle) {
         return;
     }
 
-    if(!bundle_free(m_originBundle))
-    {
+    if (!bundle_free(m_originBundle)) {
         LogDebug("Bundle data freed for new bundle data");
         m_originBundle = NULL;
     }
@@ -99,15 +92,13 @@ void ApplicationData::freeBundle()
 
 void ApplicationData::freeEncodedBundle()
 {
-    if (!m_encodedBundle)
-    {
+    if (!m_encodedBundle) {
         return;
     }
 
-    if(m_encodedBundle)
-    {
-        if(!bundle_free_encoded_rawdata(
-                    &m_encodedBundle))
+    if (m_encodedBundle) {
+        if (!bundle_free_encoded_rawdata(
+                &m_encodedBundle))
         {
             LogDebug("Bundle data freed for new bundle data");
             m_encodedBundle = NULL;
index 1b23a96..7d183ce 100644 (file)
 
 class ApplicationData
 {
-    public:
-        bundle* getBundle() const;
-        const char* getEncodedBundle() const;
-        bool setBundle(bundle *originBundle);
-        bool setEncodedBundle(bundle* originBundle);
-        void freeBundle();
-        void freeEncodedBundle();
-
-    private:
-        ApplicationData();
-        ~ApplicationData();
-
-        bundle* m_originBundle;
-        bundle_raw* m_encodedBundle;
-
-        friend class DPL::Singleton<ApplicationData>;
+  public:
+    bundle* getBundle() const;
+    const char* getEncodedBundle() const;
+    bool setBundle(bundle *originBundle);
+    bool setEncodedBundle(bundle* originBundle);
+    void freeBundle();
+    void freeEncodedBundle();
+
+  private:
+    ApplicationData();
+    ~ApplicationData();
+
+    bundle* m_originBundle;
+    bundle_raw* m_encodedBundle;
+
+    friend class DPL::Singleton<ApplicationData>;
 };
 
 typedef DPL::Singleton<ApplicationData> ApplicationDataSingleton;
old mode 100755 (executable)
new mode 100644 (file)
index 8debb43..0212c81
@@ -42,15 +42,13 @@ const char * const SCHEME_TYPE_HTML5_VIDEO = "html5video";
 }
 
 ApplicationLauncher::ApplicationLauncher()
-{
-}
+{}
 
 ApplicationLauncher::~ApplicationLauncher()
-{
-}
+{}
 
 void ApplicationLauncher::OnEventReceived(
-        const ApplicationLauncherEvents::LaunchApplicationByAppService &event)
+    const ApplicationLauncherEvents::LaunchApplicationByAppService &event)
 {
     int result;
     bundle *args = event.GetArg0();
@@ -58,12 +56,13 @@ void ApplicationLauncher::OnEventReceived(
     void *userData = event.GetArg2();
     result = appsvc_run_service(args, 0, responseCallback, userData);
 
-    if (result < 0)
+    if (result < 0) {
         LogError("Failed to run AppService : " << result);
+    }
 }
 
 void ApplicationLauncher::OnEventReceived(
-        const ApplicationLauncherEvents::LaunchApplicationByPkgname &event)
+    const ApplicationLauncherEvents::LaunchApplicationByPkgname &event)
 {
     using namespace ApplicationLauncherPkgname;
     LogDebug("LaunchApplicationByPkgname");
@@ -162,7 +161,7 @@ void ApplicationLauncher::OnEventReceived(
             url = youtube->getYouTubeHD(uri.c_str());
             delete youtube;
         } else if (SCHEME_TYPE_RTSP == scheme ||
-                    (SCHEME_TYPE_HTML5_VIDEO == scheme))
+                   (SCHEME_TYPE_HTML5_VIDEO == scheme))
         {
             url = uri.c_str();
         } else {
index d33c5e7..d1eb925 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace ApplicationLauncherEvents {
 DECLARE_GENERIC_EVENT_3(LaunchApplicationByAppService,
-                        bundle*,
+                        bundle *,
                         appsvc_res_fn,
                         void*)
 DECLARE_GENERIC_EVENT_4(LaunchApplicationByPkgname,
@@ -45,17 +45,20 @@ DECLARE_GENERIC_EVENT_4(LaunchApplicationByPkgname,
 } //namespace ApplicationLauncherEvents
 
 namespace ApplicationLauncherPkgname {
-    const std::string PKG_NAME_PREFIX = "com.samsung.";
-    const std::string PKG_NAME_DOWNLOAD_PROVIDER = PKG_NAME_PREFIX + "download-provider";
-    const std::string PKG_NAME_VIDEO_PLAYER = PKG_NAME_PREFIX + "video-player";
-    const std::string PKG_NAME_VT_MAIN = PKG_NAME_PREFIX + "vtmain";
+const std::string PKG_NAME_PREFIX = "com.samsung.";
+const std::string PKG_NAME_DOWNLOAD_PROVIDER = PKG_NAME_PREFIX +
+    "download-provider";
+const std::string PKG_NAME_VIDEO_PLAYER = PKG_NAME_PREFIX + "video-player";
+const std::string PKG_NAME_VT_MAIN = PKG_NAME_PREFIX + "vtmain";
 } // namespace ApplicationLauncherPkgname
 
 class ApplicationLauncher :
-        public DPL::Event::Controller<DPL::TypeListDecl<
-            ApplicationLauncherEvents::LaunchApplicationByPkgname,
-            ApplicationLauncherEvents::LaunchApplicationByAppService
-        >::Type>
+    public DPL::Event::Controller<DPL::TypeListDecl<
+                                      ApplicationLauncherEvents::
+                                          LaunchApplicationByPkgname,
+                                      ApplicationLauncherEvents::
+                                          LaunchApplicationByAppService
+                                      >::Type>
 {
   public:
     ApplicationLauncher();
@@ -64,10 +67,10 @@ class ApplicationLauncher :
 
   protected:
     virtual void OnEventReceived(
-            const ApplicationLauncherEvents::
+        const ApplicationLauncherEvents::
             LaunchApplicationByPkgname &event);
     virtual void OnEventReceived(
-            const ApplicationLauncherEvents::
+        const ApplicationLauncherEvents::
             LaunchApplicationByAppService &event);
 
   private:
index 087f99d..edc33d4 100644 (file)
@@ -17,7 +17,8 @@
  * @file        evas_object.cpp
  * @author      Lukasz Wrzosek (l.wrzosel@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation for Evas_Object wrapper from Efl.
+ * @brief       This file is the implementation for Evas_Object wrapper from
+ * Efl.
  */
 
 #include "evas_object.h"
@@ -35,12 +36,11 @@ void EvasObject::IConnection::Disconnect()
 
 EvasObject::IConnection::IConnection(EvasObject::EvasObjectShared* object) :
     m_object(object)
-{
-}
+{}
 
 void EvasObject::IConnection::SmartCallbackWrapper(void* data,
-        Evas_Object* /*object*/,
-        void* event_info)
+                                                   Evas_Object* /*object*/,
+                                                   void* event_info)
 {
     Assert(data);
     IConnection* Calle = static_cast<IConnection*>(data);
@@ -48,9 +48,9 @@ void EvasObject::IConnection::SmartCallbackWrapper(void* data,
 }
 
 void EvasObject::IConnection::EvasCallbackWrapper(void* data,
-        Evas* /*evas*/,
-        Evas_Object* /*object*/,
-        void* event_info)
+                                                  Evas* /*evas*/,
+                                                  Evas_Object* /*object*/,
+                                                  void* event_info)
 {
     Assert(data);
     IConnection* Calle = static_cast<IConnection*>(data);
@@ -63,12 +63,11 @@ Evas_Object* EvasObject::EvasObjectShared::GetObject()
 }
 
 EvasObject::EvasObjectShared::SmartConnectionBase::SmartConnectionBase(
-        const std::string& name,
-        EvasObject::EvasObjectShared* object) :
+    const std::string& name,
+    EvasObject::EvasObjectShared* object) :
     IConnection(object),
     m_callbackName(name)
-{
-}
+{}
 
 void EvasObject::EvasObjectShared::SmartConnectionBase::ConnectPrv()
 {
@@ -85,12 +84,11 @@ void EvasObject::EvasObjectShared::SmartConnectionBase::DisconnectPrv()
 }
 
 EvasObject::EvasObjectShared::EvasConnectionBase::EvasConnectionBase(
-        Evas_Callback_Type type,
-        EvasObject::EvasObjectShared* object) :
+    Evas_Callback_Type type,
+    EvasObject::EvasObjectShared* object) :
     IConnection(object),
     m_callbackType(type)
-{
-}
+{}
 
 void EvasObject::EvasObjectShared::EvasConnectionBase::ConnectPrv()
 {
@@ -108,8 +106,7 @@ void EvasObject::EvasObjectShared::EvasConnectionBase::DisconnectPrv()
 
 EvasObject::EvasObjectShared::EvasObjectShared() :
     m_object(NULL)
-{
-}
+{}
 
 EvasObject::EvasObjectShared::EvasObjectShared(Evas_Object* object) :
     m_object(object)
@@ -166,9 +163,9 @@ void EvasObject::EvasObjectShared::DisconnectAll()
 }
 
 void EvasObject::EvasObjectShared::StaticOnDelEvent(void* data,
-        Evas* /*e*/,
-        Evas_Object* /*o*/,
-        void* /*ev*/)
+                                                    Evas* /*e*/,
+                                                    Evas_Object* /*o*/,
+                                                    void* /*ev*/)
 {
     Assert(data);
     EvasObjectShared* This = static_cast<EvasObjectShared*>(data);
@@ -183,23 +180,19 @@ void EvasObject::EvasObjectShared::StaticOnDelEvent(void* data,
 
 EvasObject::EvasObject() :
     m_object(new EvasObjectShared())
-{
-}
+{}
 
 EvasObject::EvasObject(Evas_Object* object) :
     m_object(new EvasObjectShared(object))
-{
-}
+{}
 
 EvasObject::EvasObject(const EvasObject& other) :
     m_object(other.m_object)
-{
-}
+{}
 
 //this destructor must be here to let pimpl with shared_ptr work without warning
 EvasObject::~EvasObject()
-{
-}
+{}
 
 EvasObject& EvasObject::operator=(const EvasObject& other)
 {
index 7f8585d..5073919 100644 (file)
@@ -49,17 +49,16 @@ class EvasObject
       private:
         IConnection(EvasObjectShared* object);
         virtual ~IConnection()
-        {
-        }
+        {}
         virtual void Call(void* /*event_info*/) = 0;
 
         static void SmartCallbackWrapper(void* data,
-                Evas_Object* /*object*/,
-                void* event_info);
+                                         Evas_Object* /*object*/,
+                                         void* event_info);
         static void EvasCallbackWrapper(void* data,
-                Evas* /*evas*/,
-                Evas_Object* /*object*/,
-                void* event_info);
+                                        Evas* /*evas*/,
+                                        Evas_Object* /*object*/,
+                                        void* event_info);
 
         virtual void ConnectPrv() = 0;
         virtual void DisconnectPrv() = 0;
@@ -82,7 +81,7 @@ class EvasObject
         {
           public:
             SmartConnectionBase(const std::string& name,
-                    EvasObjectShared* object);
+                                EvasObjectShared* object);
 
             virtual void ConnectPrv();
             virtual void DisconnectPrv();
@@ -98,18 +97,16 @@ class EvasObject
                                    Args ... args);
 
             SmartConnection(const std::string& name,
-                    CbType callback,
-                    EvasObjectShared* object,
-                    Args ... args) :
+                            CbType callback,
+                            EvasObjectShared* object,
+                            Args ... args) :
                 SmartConnectionBase(name, object),
                 m_callback(callback),
                 m_args(args ...)
-            {
-            }
+            {}
 
             virtual ~SmartConnection()
-            {
-            }
+            {}
 
             virtual void Call(void* event_info)
             {
@@ -133,20 +130,18 @@ class EvasObject
                                              void* event_info, ArgType1 *arg1);
 
             SmartMemberConnection1(const std::string& name,
-                    CbType callback,
-                    ThisType* callee,
-                    ArgType1* arg1,
-                    EvasObjectShared* object) :
+                                   CbType callback,
+                                   ThisType* callee,
+                                   ArgType1* arg1,
+                                   EvasObjectShared* object) :
                 SmartConnectionBase(name, object),
                 m_callback(callback),
                 m_callee(callee),
                 m_arg1(arg1)
-            {
-            }
+            {}
 
             virtual ~SmartMemberConnection1()
-            {
-            }
+            {}
 
             virtual void Call(void* event_info)
             {
@@ -168,22 +163,20 @@ class EvasObject
                                              ArgType2* arg2);
 
             SmartMemberConnection2(const std::string& name,
-                    CbType callback,
-                    ThisType* callee,
-                    ArgType1* arg1,
-                    ArgType2* arg2,
-                    EvasObjectShared* object) :
+                                   CbType callback,
+                                   ThisType* callee,
+                                   ArgType1* arg1,
+                                   ArgType2* arg2,
+                                   EvasObjectShared* object) :
                 SmartConnectionBase(name, object),
                 m_callback(callback),
                 m_callee(callee),
                 m_arg1(arg1),
                 m_arg2(arg2)
-            {
-            }
+            {}
 
             virtual ~SmartMemberConnection2()
-            {
-            }
+            {}
 
             virtual void Call(void* event_info)
             {
@@ -201,7 +194,7 @@ class EvasObject
         {
           public:
             EvasConnectionBase(Evas_Callback_Type type,
-                    EvasObjectShared* object);
+                               EvasObjectShared* object);
 
             virtual void ConnectPrv();
             virtual void DisconnectPrv();
@@ -217,18 +210,16 @@ class EvasObject
                                    ArgType1 *arg1);
 
             EvasConnection1(Evas_Callback_Type type,
-                    CbType callback,
-                    ArgType1* arg1,
-                    EvasObjectShared* object) :
+                            CbType callback,
+                            ArgType1* arg1,
+                            EvasObjectShared* object) :
                 EvasConnectionBase(type, object),
                 m_callback(callback),
                 m_arg1(arg1)
-            {
-            }
+            {}
 
             virtual ~EvasConnection1()
-            {
-            }
+            {}
 
             virtual void Call(void* event_info)
             {
@@ -248,20 +239,18 @@ class EvasObject
                                    ArgType1 *arg1, ArgType2 *arg2);
 
             EvasConnection2(Evas_Callback_Type type,
-                    CbType callback,
-                    ArgType1* arg1,
-                    ArgType2* arg2,
-                    EvasObjectShared* object) :
+                            CbType callback,
+                            ArgType1* arg1,
+                            ArgType2* arg2,
+                            EvasObjectShared* object) :
                 EvasConnectionBase(type, object),
                 m_callback(callback),
                 m_arg1(arg1),
                 m_arg2(arg2)
-            {
-            }
+            {}
 
             virtual ~EvasConnection2()
-            {
-            }
+            {}
 
             virtual void Call(void* event_info)
             {
@@ -282,20 +271,18 @@ class EvasObject
                                              void* event_info, ArgType1 *arg1);
 
             EvasMemberConnection1(Evas_Callback_Type type,
-                    CbType callback,
-                    ThisType* callee,
-                    ArgType1* arg1,
-                    EvasObjectShared* object) :
+                                  CbType callback,
+                                  ThisType* callee,
+                                  ArgType1* arg1,
+                                  EvasObjectShared* object) :
                 EvasConnectionBase(type, object),
                 m_callback(callback),
                 m_callee(callee),
                 m_arg1(arg1)
-            {
-            }
+            {}
 
             virtual ~EvasMemberConnection1()
-            {
-            }
+            {}
 
             virtual void Call(void* event_info)
             {
@@ -317,22 +304,20 @@ class EvasObject
                                              ArgType2* arg2);
 
             EvasMemberConnection2(Evas_Callback_Type type,
-                    CbType callback,
-                    ThisType* callee,
-                    ArgType1* arg1,
-                    ArgType2* arg2,
-                    EvasObjectShared* object) :
+                                  CbType callback,
+                                  ThisType* callee,
+                                  ArgType1* arg1,
+                                  ArgType2* arg2,
+                                  EvasObjectShared* object) :
                 EvasConnectionBase(type, object),
                 m_callback(callback),
                 m_callee(callee),
                 m_arg1(arg1),
                 m_arg2(arg2)
-            {
-            }
+            {}
 
             virtual ~EvasMemberConnection2()
-            {
-            }
+            {}
 
             virtual void Call(void* event_info)
             {
@@ -352,9 +337,11 @@ class EvasObject
         ~EvasObjectShared();
 
         template<typename ... Args>
-        IConnection* ConnectSmartCallback(const char* callbackName,
-                typename SmartConnection<Args ...>::CbType callback,
-                Args ... args)
+        IConnection* ConnectSmartCallback(
+            const char* callbackName,
+            typename SmartConnection<Args ...>::
+                CbType callback,
+            Args ... args)
         {
             Assert(m_object);
             Assert(callbackName);
@@ -371,12 +358,12 @@ class EvasObject
 
         template <class ThisType, class ArgType1, class ArgType2>
         IConnection* ConnectMemberSmartCallback(
-                const char* callbackName,
-                typename SmartMemberConnection2<ThisType, ArgType1,
-                                                ArgType2>::CbType callback,
-                ThisType* callee,
-                ArgType1* arg1,
-                ArgType2* arg2)
+            const char* callbackName,
+            typename SmartMemberConnection2<ThisType, ArgType1,
+                                            ArgType2>::CbType callback,
+            ThisType* callee,
+            ArgType1* arg1,
+            ArgType2* arg2)
         {
             Assert(m_object);
             Assert(callee);
@@ -397,11 +384,11 @@ class EvasObject
 
         template <class ThisType, class ArgType1>
         IConnection* ConnectMemberSmartCallback(
-                const char* callbackName,
-                typename SmartMemberConnection1<ThisType,
-                                                ArgType1>::CbType callback,
-                ThisType* callee,
-                ArgType1* arg1)
+            const char* callbackName,
+            typename SmartMemberConnection1<ThisType,
+                                            ArgType1>::CbType callback,
+            ThisType* callee,
+            ArgType1* arg1)
         {
             Assert(m_object);
             Assert(callee);
@@ -420,9 +407,11 @@ class EvasObject
 
         template <class ArgType1, class ArgType2>
         IConnection* ConnectEvasCallback(Evas_Callback_Type callbackType,
-                typename EvasConnection2<ArgType1, ArgType2>::CbType callback,
-                ArgType1* arg1,
-                ArgType2* arg2)
+                                         typename EvasConnection2<ArgType1,
+                                                                  ArgType2>::
+                                             CbType callback,
+                                         ArgType1* arg1,
+                                         ArgType2* arg2)
         {
             Assert(m_object);
             Assert(callbackType);
@@ -439,9 +428,11 @@ class EvasObject
         }
 
         template <class ArgType1>
-        IConnection* ConnectEvasCallback(Evas_Callback_Type callbackType,
-                typename EvasConnection1<ArgType1>::CbType callback,
-                ArgType1* arg1)
+        IConnection* ConnectEvasCallback(
+            Evas_Callback_Type callbackType,
+            typename EvasConnection1<ArgType1>::
+                CbType callback,
+            ArgType1* arg1)
         {
             Assert(m_object);
             Assert(callbackType);
@@ -458,12 +449,12 @@ class EvasObject
 
         template <class ThisType, class ArgType1, class ArgType2>
         IConnection* ConnectMemberEvasCallback(
-                Evas_Callback_Type callbackType,
-                typename EvasMemberConnection2<ThisType, ArgType1,
-                                               ArgType2>::CbType callback,
-                ThisType* callee,
-                ArgType1* arg1,
-                ArgType2* arg2)
+            Evas_Callback_Type callbackType,
+            typename EvasMemberConnection2<ThisType, ArgType1,
+                                           ArgType2>::CbType callback,
+            ThisType* callee,
+            ArgType1* arg1,
+            ArgType2* arg2)
         {
             Assert(m_object);
             Assert(callee);
@@ -484,11 +475,11 @@ class EvasObject
 
         template <class ThisType, class ArgType1>
         IConnection* ConnectMemberEvasCallback(
-                Evas_Callback_Type callbackType,
-                typename EvasMemberConnection1<ThisType,
-                                               ArgType1>::CbType callback,
-                ThisType* callee,
-                ArgType1* arg1)
+            Evas_Callback_Type callbackType,
+            typename EvasMemberConnection1<ThisType,
+                                           ArgType1>::CbType callback,
+            ThisType* callee,
+            ArgType1* arg1)
         {
             Assert(m_object);
             Assert(callee);
@@ -509,9 +500,9 @@ class EvasObject
         void DisconnectAll();
 
         static void StaticOnDelEvent(void* data,
-                Evas* /*e*/,
-                Evas_Object* /*o*/,
-                void* /*ev*/);
+                                     Evas* /*e*/,
+                                     Evas_Object* /*o*/,
+                                     void* /*ev*/);
 
         IConnectionsSet m_connections;
         Evas_Object* m_object;
@@ -539,10 +530,10 @@ class EvasObject
 
     template <class ... Args>
     IConnection* ConnectSmartCallback(
-            const char* callbackName,
-            typename EvasObjectShared::SmartConnection<Args ...>::CbType
-            callback,
-            Args ... args)
+        const char* callbackName,
+        typename EvasObjectShared::SmartConnection<Args ...>::CbType
+        callback,
+        Args ... args)
     {
         Assert(m_object);
         return m_object->ConnectSmartCallback(callbackName, callback, args ...);
@@ -550,14 +541,14 @@ class EvasObject
 
     template <class ThisType, class ArgType1, class ArgType2>
     IConnection* ConnectMemberSmartCallback(
-            const char* callbackName,
-            typename EvasObjectShared::SmartMemberConnection2<ThisType,
-                                                              ArgType1,
-                                                              ArgType2>::CbType
-            callback,
-            ThisType* callee,
-            ArgType1* arg1,
-            ArgType2* arg2)
+        const char* callbackName,
+        typename EvasObjectShared::SmartMemberConnection2<ThisType,
+                                                          ArgType1,
+                                                          ArgType2>::CbType
+        callback,
+        ThisType* callee,
+        ArgType1* arg1,
+        ArgType2* arg2)
     {
         Assert(m_object);
         Assert(callee);
@@ -571,12 +562,12 @@ class EvasObject
 
     template <class ThisType, class ArgType1>
     IConnection* ConnectMemberSmartCallback(
-            const char* callbackName,
-            typename EvasObjectShared::SmartMemberConnection1<ThisType,
-                                                              ArgType1>::CbType
-            callback,
-            ThisType* callee,
-            ArgType1* arg1)
+        const char* callbackName,
+        typename EvasObjectShared::SmartMemberConnection1<ThisType,
+                                                          ArgType1>::CbType
+        callback,
+        ThisType* callee,
+        ArgType1* arg1)
     {
         Assert(m_object);
         Assert(callee);
@@ -589,11 +580,11 @@ class EvasObject
 
     template <class ArgType1, class ArgType2>
     IConnection* ConnectEvasCallback(
-            Evas_Callback_Type callbackType,
-            typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
-            callback,
-            ArgType1* arg1,
-            ArgType2* arg2)
+        Evas_Callback_Type callbackType,
+        typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
+        callback,
+        ArgType1* arg1,
+        ArgType2* arg2)
     {
         Assert(m_object);
         return m_object->ConnectEvasCallback(callbackType, callback, arg1, arg2);
@@ -601,10 +592,10 @@ class EvasObject
 
     template <class ArgType1>
     IConnection* ConnectEvasCallback(
-            Evas_Callback_Type callbackType,
-            typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
-            callback,
-            ArgType1* arg1)
+        Evas_Callback_Type callbackType,
+        typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
+        callback,
+        ArgType1* arg1)
     {
         Assert(m_object);
         return m_object->ConnectEvasCallback(callbackType, callback, arg1);
@@ -612,12 +603,12 @@ class EvasObject
 
     template <class ThisType, class ArgType1>
     IConnection* ConnectMemberEvasCallback(
-            Evas_Callback_Type callbackType,
-            typename EvasObjectShared::EvasMemberConnection1<ThisType,
-                                                             ArgType1>::CbType
-            callback,
-            ThisType* callee,
-            ArgType1* arg1)
+        Evas_Callback_Type callbackType,
+        typename EvasObjectShared::EvasMemberConnection1<ThisType,
+                                                         ArgType1>::CbType
+        callback,
+        ThisType* callee,
+        ArgType1* arg1)
     {
         Assert(m_object);
         Assert(callee);
@@ -630,13 +621,13 @@ class EvasObject
 
     template <class ThisType, class ArgType1, class ArgType2>
     IConnection* ConnectMemberEvasCallback(
-            Evas_Callback_Type callbackType,
-            typename EvasObjectShared::EvasMemberConnection2<ThisType, ArgType1,
-                                                             ArgType2>::CbType
-            callback,
-            ThisType* callee,
-            ArgType1* arg1,
-            ArgType2* arg2)
+        Evas_Callback_Type callbackType,
+        typename EvasObjectShared::EvasMemberConnection2<ThisType, ArgType1,
+                                                         ArgType2>::CbType
+        callback,
+        ThisType* callee,
+        ArgType1* arg1,
+        ArgType2* arg2)
     {
         Assert(m_object);
         Assert(callee);
index b366190..7539c10 100644 (file)
 #include <dpl/log/log.h>
 
 namespace ViewModule {
-
 namespace {
-
 const char * const type2name[Scheme::COUNT] = {
-        "file",
-        "sms",
-        "mmsto",
-        "mailto",
-        "data",
-        "tel",
-        "http",
-        "https",
-        "widget",
-        "vnd.youtube",
-        "rtsp" };
+    "file",
+    "sms",
+    "mmsto",
+    "mailto",
+    "data",
+    "tel",
+    "http",
+    "https",
+    "widget",
+    "vnd.youtube",
+    "rtsp"
+};
 
 typedef std::map<std::string, Scheme::Type> SchemeMap;
 
@@ -46,7 +45,7 @@ SchemeMap PopulateMap()
 {
     LogInfo("Populating scheme map...");
     SchemeMap map;
-    for(size_t st = Scheme::FILE; st<Scheme::COUNT;++st) {
+    for (size_t st = Scheme::FILE; st < Scheme::COUNT; ++st) {
         LogInfo(" * " << type2name[st] << "->" << st);
         map[type2name[st]] = static_cast<Scheme::Type>(st);
     }
@@ -54,10 +53,10 @@ SchemeMap PopulateMap()
 }
 
 const SchemeMap name2type = PopulateMap();
-
 } // namespace
 
-Scheme::Scheme(const std::string& name) : m_name(name), m_type(INVALID) {
+Scheme::Scheme(const std::string& name) : m_name(name), m_type(INVALID)
+{
     m_type = GetType(name);
 }
 
@@ -70,11 +69,10 @@ std::string Scheme::GetName (Type type)
 Scheme::Type Scheme::GetType(const std::string& name)
 {
     auto it = name2type.find(name);
-    if(it == name2type.end()) {
+    if (it == name2type.end()) {
         LogError("Invalid scheme: " << name);
         return INVALID;
     }
     return it->second;
 }
-
 } /* namespace ViewModule */
index 5bc5729..e004efa 100644 (file)
@@ -25,9 +25,9 @@
 #include <string>
 
 namespace ViewModule {
-
-class Scheme {
-public:
+class Scheme
+{
+  public:
     enum Type {
         INVALID = -1,
         FILE = 0,
@@ -48,8 +48,14 @@ public:
     explicit Scheme(const std::string& name);
     virtual ~Scheme() {}
 
-    std::string GetName() const { return m_name; }
-    Type GetType() const { return m_type; }
+    std::string GetName() const
+    {
+        return m_name;
+    }
+    Type GetType() const
+    {
+        return m_type;
+    }
 
     static std::string GetName (Type type);
     static std::string GetName (size_t type)
@@ -58,10 +64,9 @@ public:
     }
     static Type GetType(const std::string& name);
 
-private:
+  private:
     std::string m_name;
     Type m_type;
 };
-
 } /* namespace ViewModule */
 #endif /* SCHEME_H_ */
index 2d2a46a..a86b728 100644 (file)
@@ -31,9 +31,7 @@
 #include "scheme_action_map_data.h"
 
 namespace ViewModule {
-
 namespace {
-
 /*
  * Lazy construction pattern.
  * TODO Make it more general. Use variadic template/tuples/lambdas or sth. Move
@@ -42,22 +40,32 @@ namespace {
 template <typename T, typename Arg1>
 class Lazy
 {
-public:
+  public:
     explicit Lazy(const Arg1& arg1) :
         m_arg1(arg1),
         m_object(new std::unique_ptr<T>())
-    {
-    }
+    {}
     Lazy(const Lazy<T, Arg1>& other) :
         m_arg1(other.m_arg1),
         m_object(other.m_object)
+    {}
+
+    T& operator*()
     {
+        return GetObject();
+    }
+    const T& operator*() const
+    {
+        return GetObject();
+    }
+    const T* operator->() const
+    {
+        return &GetObject();
+    }
+    T* operator->()
+    {
+        return &GetObject();
     }
-
-    T& operator*()  { return GetObject(); }
-    const T& operator*() const { return GetObject(); }
-    const T* operator->() const  { return &GetObject(); }
-    T* operator->() { return &GetObject(); }
 
     Lazy<T, Arg1>& operator=(const Lazy<T, Arg1>& other)
     {
@@ -65,7 +73,8 @@ public:
         m_object = other.m_object;
         return *this;
     }
-private:
+
+  private:
     T& GetObject() const
     {
         if (!(*m_object)) {
@@ -84,12 +93,12 @@ private:
  * sms:5551212?body=expected%20text => APPSVC_DATA_TEXT + expected%20text
  */
 struct AppSvcConversion {
-    AppSvcConversion(char const * const keyValue, const std::string& regexStr):
+    AppSvcConversion(char const * const keyValue,
+                     const std::string& regexStr) :
         key(keyValue),
-        regex(regexStr) {
-    }
+        regex(regexStr) {}
     char const * const key;
-    Lazy<pcrecpp::RE,std::string> regex;
+    Lazy<pcrecpp::RE, std::string> regex;
 };
 
 /*
@@ -106,14 +115,14 @@ typedef std::map<Scheme::Type, AppSvcOperation> AppSvcOperationMap;
 
 // Regular expressions used to extract appsvc data from scheme
 // TODO what about multiple recipients?
-char const * const REGEX_BODY =         ".*[?&]body=([^&]+).*";
-char const * const REGEX_SMS =           "sms:([^&]+).*";
-char const * const REGEX_MMSTO =        "mmsto:([^&]+).*";
-char const * const REGEX_MAILTO =       "mailto:([^&]+).*";
-char const * const REGEX_TO =           ".*[?&]to=([^&]+).*";
-char const * const REGEX_CC =           ".*[?&]cc=([^&]+).*";
-char const * const REGEX_BCC =          ".*[?&]bcc=([^&]+).*";
-char const * const REGEX_SUBJECT =      ".*[?&]subject=([^&]+).*";
+char const * const REGEX_BODY = ".*[?&]body=([^&]+).*";
+char const * const REGEX_SMS = "sms:([^&]+).*";
+char const * const REGEX_MMSTO = "mmsto:([^&]+).*";
+char const * const REGEX_MAILTO = "mailto:([^&]+).*";
+char const * const REGEX_TO = ".*[?&]to=([^&]+).*";
+char const * const REGEX_CC = ".*[?&]cc=([^&]+).*";
+char const * const REGEX_BCC = ".*[?&]bcc=([^&]+).*";
+char const * const REGEX_SUBJECT = ".*[?&]subject=([^&]+).*";
 char const * const REGEX_DATA_CONTEXT = ".*;phone-context=([^:]+).*";
 
 AppSvcOperationMap initializeAppSvcOperations()
@@ -140,16 +149,16 @@ AppSvcOperationMap initializeAppSvcOperations()
     // MMSTO & MAILTO
     AppSvcOperation sendOp;
     sendOp.operation = APPSVC_OPERATION_SEND;
-    sendOp.needUri = false;
+    sendOp.needUri = true;
     sendOp.conversions.push_back(AppSvcConversion(APPSVC_DATA_TO, REGEX_MMSTO));
     sendOp.conversions.push_back(AppSvcConversion(APPSVC_DATA_TO, REGEX_MAILTO));
     sendOp.conversions.push_back(AppSvcConversion(APPSVC_DATA_CC, REGEX_CC));
     sendOp.conversions.push_back(
-            AppSvcConversion(APPSVC_DATA_BCC, REGEX_BCC));
+        AppSvcConversion(APPSVC_DATA_BCC, REGEX_BCC));
     sendOp.conversions.push_back(
-            AppSvcConversion(APPSVC_DATA_SUBJECT, REGEX_SUBJECT));
+        AppSvcConversion(APPSVC_DATA_SUBJECT, REGEX_SUBJECT));
     sendOp.conversions.push_back(
-            AppSvcConversion(APPSVC_DATA_TEXT, REGEX_BODY));
+        AppSvcConversion(APPSVC_DATA_TEXT, REGEX_BODY));
     ret.insert(std::make_pair(Scheme::MMSTO, sendOp));
     ret.insert(std::make_pair(Scheme::MAILTO, sendOp));
 
@@ -158,21 +167,16 @@ AppSvcOperationMap initializeAppSvcOperations()
     // TEL
     AppSvcOperation telOp;
     telOp.operation = APPSVC_OPERATION_CALL;
-    telOp.needUri = false;
-    //telOp.conversions.push_back(
-    //      AppSvcConversion(APPSVC_DATA_CONTEXT, REGEX_DATA_CONTEXT)); //TODO
+    telOp.needUri = true;
     ret.insert(std::make_pair(Scheme::TEL, telOp));
 
     return ret;
 }
 
 AppSvcOperationMap g_appSvcOperationMap = initializeAppSvcOperations();
-
 } // namespace
 
-
 namespace SchemeActionMap {
-
 bool HandleUri(const char* uri,
                NavigationContext context,
                WrtDB::AppType appType)
@@ -195,6 +199,18 @@ bool HandleUri(const char* uri,
     Scheme::Type type = scheme.GetType();
     if (type < Scheme::FILE || type >= Scheme::COUNT) {
         LogError("Invalid scheme: " << name);
+        // case of unknown scheme, send to app-control
+        // This is temporary soultion. "invalid" scheme should be handled by
+        // scheme map data
+        bundle* bundleData = bundle_create();
+        appsvc_set_operation(bundleData, APPSVC_OPERATION_VIEW);
+        appsvc_set_uri(bundleData, uri);
+        CONTROLLER_POST_EVENT(
+            ApplicationLauncher,
+            ApplicationLauncherEvents::LaunchApplicationByAppService(
+                bundleData,
+                NULL,
+                NULL));
         return false;
     }
 
@@ -262,29 +278,27 @@ bool HandleUri(const char* uri,
 
         // TODO do we need a callback?
         CONTROLLER_POST_EVENT(
-                ApplicationLauncher,
-                ApplicationLauncherEvents::LaunchApplicationByAppService(
-                        bundleData,
-                        NULL,
-                        NULL));
+            ApplicationLauncher,
+            ApplicationLauncherEvents::LaunchApplicationByAppService(
+                bundleData,
+                NULL,
+                NULL));
         break;
     }
 
     case URI_ACTION_VIDEO:
         CONTROLLER_POST_EVENT(
-                ApplicationLauncher,
-                ApplicationLauncherEvents::LaunchApplicationByPkgname(
-                        ApplicationLauncherPkgname::PKG_NAME_VIDEO_PLAYER,
-                        name,
-                        uri,
-                        "null"));
+            ApplicationLauncher,
+            ApplicationLauncherEvents::LaunchApplicationByPkgname(
+                ApplicationLauncherPkgname::PKG_NAME_VIDEO_PLAYER,
+                name,
+                uri,
+                "null"));
         break;
     default:
         break;
     }
     return (action == URI_ACTION_WRT);
 }
-
 } // namespace SchemeActionMap
-
 } /* namespace ViewModule */
index 558693d..029d3e8 100644 (file)
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace ViewModule {
-
 namespace SchemeActionMap {
-    bool HandleUri(const char* uri, NavigationContext context, WrtDB::AppType appType);
+bool HandleUri(const char* uri,
+               NavigationContext context,
+               WrtDB::AppType appType);
 };
-
 } /* namespace ViewModule */
 #endif /* SCHEME_ACTION_MAP_H_ */
index 6710222..3a13f31 100644 (file)
@@ -23,9 +23,7 @@
 #include <scheme.h>
 
 namespace ViewModule {
-
 namespace {
-
 enum UriAction {
     URI_ACTION_WRT,       // load in WRT
     URI_ACTION_APPSVC,    // launch in APPSVC
@@ -61,38 +59,34 @@ enum UriAction {
 
 // TIZEN
 const UriAction g_tizenActionMap[Scheme::COUNT][SchemeActionMap::COUNT] = {
-
-//  TOP_LEVEL           FRAME_LEVEL         NEW_WINDOW
-    {URI_ACTION_WRT,    URI_ACTION_WRT,     URI_ACTION_WRT},      // FILE
-    {URI_ACTION_APPSVC, URI_ACTION_APPSVC,  URI_ACTION_APPSVC},   // SMS
-    {URI_ACTION_APPSVC, URI_ACTION_APPSVC,  URI_ACTION_APPSVC},   // MMSTO
-    {URI_ACTION_APPSVC, URI_ACTION_APPSVC,  URI_ACTION_APPSVC},   // MAILTO
-    {URI_ACTION_WRT,    URI_ACTION_WRT,     URI_ACTION_WRT},   // DATA
-    {URI_ACTION_APPSVC, URI_ACTION_APPSVC,  URI_ACTION_APPSVC},   // TEL
-    {URI_ACTION_WRT,    URI_ACTION_WRT,     URI_ACTION_WRT},      // HTTP
-    {URI_ACTION_WRT,    URI_ACTION_WRT,     URI_ACTION_WRT},      // HTTPS
-    {URI_ACTION_WRT,    URI_ACTION_WRT,     URI_ACTION_WRT},      // WIDGET
-    {URI_ACTION_VIDEO,  URI_ACTION_VIDEO,   URI_ACTION_VIDEO},    // YOUTUBE
-    {URI_ACTION_VIDEO,  URI_ACTION_VIDEO,   URI_ACTION_VIDEO}     // RTSP
+    //  TOP_LEVEL           FRAME_LEVEL         NEW_WINDOW
+    { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT },           // FILE
+    { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC },  // SMS
+    { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC },  // MMSTO
+    { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC },  // MAILTO
+    { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT },        // DATA
+    { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC },  // TEL
+    { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT },           // HTTP
+    { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT },           // HTTPS
+    { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT },           // WIDGET
+    { URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO },     // YOUTUBE
+    { URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO }      // RTSP
 };
 
 // WAC
 const UriAction g_wacActionMap[Scheme::COUNT][SchemeActionMap::COUNT] = {
-
-//  TOP_LEVEL           FRAME_LEVEL         NEW_WINDOW
-    {URI_ACTION_WRT,    URI_ACTION_WRT,     URI_ACTION_APPSVC},   // FILE
-    {URI_ACTION_APPSVC, URI_ACTION_APPSVC,  URI_ACTION_APPSVC},   // SMS
-    {URI_ACTION_APPSVC, URI_ACTION_APPSVC,  URI_ACTION_APPSVC},   // MMSTO
-    {URI_ACTION_APPSVC, URI_ACTION_APPSVC,  URI_ACTION_APPSVC},   // MAILTO
-    {URI_ACTION_WRT,    URI_ACTION_WRT,     URI_ACTION_WRT},   // DATA
-    {URI_ACTION_APPSVC, URI_ACTION_APPSVC,  URI_ACTION_APPSVC},   // TEL
-    {URI_ACTION_APPSVC, URI_ACTION_WRT,     URI_ACTION_APPSVC},   // HTTP
-    {URI_ACTION_APPSVC, URI_ACTION_WRT,     URI_ACTION_APPSVC},   // HTTPS
-    {URI_ACTION_WRT,    URI_ACTION_WRT,     URI_ACTION_APPSVC},   // WIDGET
-    {URI_ACTION_VIDEO,  URI_ACTION_VIDEO,   URI_ACTION_VIDEO},    // YOUTUBE
-    {URI_ACTION_VIDEO,  URI_ACTION_VIDEO,   URI_ACTION_VIDEO}     // RTSP
+    //  TOP_LEVEL           FRAME_LEVEL         NEW_WINDOW
+    { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_APPSVC },        // FILE
+    { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC },  // SMS
+    { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC },  // MMSTO
+    { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC },  // MAILTO
+    { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT },        // DATA
+    { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC },  // TEL
+    { URI_ACTION_APPSVC, URI_ACTION_WRT, URI_ACTION_APPSVC },     // HTTP
+    { URI_ACTION_APPSVC, URI_ACTION_WRT, URI_ACTION_APPSVC },     // HTTPS
+    { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_APPSVC },        // WIDGET
+    { URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO },     // YOUTUBE
+    { URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO }      // RTSP
 };
-
 }
-
 }
index 05e3bb7..334e01e 100644 (file)
 
 namespace ViewModule {
 namespace SchemeActionMap {
-    enum NavigationContext {
-        TOP_LEVEL = 0,
-        FRAME_LEVEL,
-        NEW_WINDOW,
+enum NavigationContext {
+    TOP_LEVEL = 0,
+    FRAME_LEVEL,
+    NEW_WINDOW,
 
-        COUNT
-    };
+    COUNT
+};
 } // namespace SchemeActionMap
 } // namespace ViewModule
 #endif /* SCHEME_ACTION_MAP_TYPE_H_ */
index 84e48c0..78c96d9 100644 (file)
@@ -28,7 +28,6 @@
 #include <application_launcher.h>
 
 namespace ViewModule {
-
 namespace {
 const char* const SCHEME_TYPE_HTML5_VIDEO = "html5video";
 const char* const HTTP_STREAMING_MPEG_MIMETYPE = "application/x-mpegurl";
@@ -52,8 +51,7 @@ class AppsSupportImplementation
     AppsSupportImplementation() :
         m_widgetModel(NULL),
         m_initialized(false)
-    {
-    }
+    {}
 
     ~AppsSupportImplementation()
     {
@@ -72,7 +70,7 @@ class AppsSupportImplementation
         ApplicationLauncherSingleton::Instance().Touch();
 
         ApplicationLauncherSingleton::Instance().setWidgetTizenId(
-                DPL::ToUTF8String(m_widgetModel->TizenId));
+            DPL::ToUTF8String(m_widgetModel->TizenId));
 
         LogDebug("Initialized");
         m_initialized = true;
@@ -144,8 +142,8 @@ class AppsSupportImplementation
 
         // ignore case match of string of mime type
         int isAppServiceable = httpMultimediaRequest(
-            mimeType ? std::string(mimeType) : "null",
-            url ? std::string(url) : "null");
+                mimeType ? std::string(mimeType) : "null",
+                url ? std::string(url) : "null");
 
         if (isAppServiceable) {
             LogInfo("Application Service start");
@@ -157,8 +155,8 @@ class AppsSupportImplementation
             ApplicationLauncherEvents::LaunchApplicationByPkgname(
                 ApplicationLauncherPkgname::PKG_NAME_DOWNLOAD_PROVIDER,
                 url ? std::string(url) : "null",
-                mimeType ? mimeType : "null",
-                userParam ? userParam : "null"));
+                !mimeType && strlen(mimeType) != 0 ? mimeType : "null",
+                !userParam && strlen(userParam) != 0 ? userParam : "null"));
     }
 
     void html5VideoRequest(void* event_info)
@@ -183,13 +181,11 @@ class AppsSupportImplementation
     }
 };
 
-AppsSupport::AppsSupport(): m_impl(new AppsSupportImplementation)
-{
-}
+AppsSupport::AppsSupport() : m_impl(new AppsSupportImplementation)
+{}
 
 AppsSupport::~AppsSupport()
-{
-}
+{}
 
 void AppsSupport::initialize(WidgetModel *widgetModel)
 {
@@ -212,5 +208,4 @@ void AppsSupport::downloadRequest(const char *url,
 {
     m_impl->downloadRequest(url, mimeType, userParam);
 }
-
-}//namespace
+} //namespace
index a84a671..aeb89fc 100644 (file)
@@ -28,7 +28,6 @@
 class WidgetModel; //Forward declaration
 
 namespace ViewModule {
-
 class AppsSupportImplementation; //Forward declaration
 
 class AppsSupport
@@ -41,14 +40,13 @@ class AppsSupport
     void deinitialize();
     void html5VideoRequest(void* event_info);
     void downloadRequest(
-            const char *url,
-            const char *mimeType,
-            const char *userParam);
+        const char *url,
+        const char *mimeType,
+        const char *userParam);
 
   private:
     std::unique_ptr<AppsSupportImplementation> m_impl;
 };
-
 } //namespace
 
 #endif /* VIEW_LOGIC_APPS_SUPPORT_H_ */
diff --git a/src/view/common/view_logic_certificate_support.cpp b/src/view/common/view_logic_certificate_support.cpp
new file mode 100755 (executable)
index 0000000..308157c
--- /dev/null
@@ -0,0 +1,187 @@
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ *    Licensed under the Apache License, Version 2.0 (the "License");\r
+ *    you may not use this file except in compliance with the License.\r
+ *    You may obtain a copy of the License at\r
+ *\r
+ *        http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *    Unless required by applicable law or agreed to in writing, software\r
+ *    distributed under the License is distributed on an "AS IS" BASIS,\r
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *    See the License for the specific language governing permissions and\r
+ *    limitations under the License.\r
+ */\r
+/**\r
+ * @file    view_logic_certificate_origin_support.cpp\r
+ * @author  Leerang Song (leerang.song@samsung.com)\r
+ * @version 1.0\r
+ * @brief   Support certificate dao\r
+ */\r
+\r
+#include "view_logic_certificate_support.h"\r
+\r
+#include <memory>\r
+#include <Evas.h>\r
+#include <Elementary.h>\r
+#include <vconf.h>\r
+#include <dpl/log/log.h>\r
+#include <dpl/assert.h>\r
+#include <dpl/wrt-dao-ro/common_dao_types.h>\r
+#include <dpl/wrt-dao-ro/vconf_config.h>\r
+#include <wrt-commons/certificate-dao/certificate_dao.h>\r
+#include <widget_model.h>\r
+\r
+namespace ViewModule {\r
+namespace {\r
+const char* const DAEMON_EDJ_PATH = "/usr/share/edje/wrt/Daemon.edj";\r
+}\r
+\r
+class CertificateSupportImplementation\r
+{\r
+  private:\r
+    WidgetModel* m_model;\r
+    CertificateDB::CertificateDAOPtr m_certificateDAO;\r
+\r
+  public:\r
+    CertificateSupportImplementation(WidgetModel* widgetModel) :\r
+        m_model(NULL)\r
+    {\r
+        Assert(widgetModel);\r
+        m_model = widgetModel;\r
+    }\r
+\r
+    ~CertificateSupportImplementation()\r
+    {}\r
+\r
+    CertificateDB::CertificateDAO* getCertificateDAO(void)\r
+    {\r
+        Assert(m_model);\r
+        if (!m_certificateDAO) {\r
+            LogDebug("initialize CertificateDAO");\r
+            m_certificateDAO =\r
+                CertificateDB::CertificateDAOPtr(\r
+                    new CertificateDB::CertificateDAO(m_model->TzPkgId.\r
+                                                                Get()));\r
+            // initialize certificate result data. Remove allow, deny for\r
+            m_certificateDAO->removeCertificateData(\r
+                CertificateDB::RESULT_ALLOW_ONCE);\r
+            m_certificateDAO->removeCertificateData(\r
+                CertificateDB::RESULT_DENY_ONCE);\r
+        }\r
+        return m_certificateDAO.get();\r
+    }\r
+};\r
+\r
+CertificateSupport::CertificateSupport(WidgetModel* widgetModel) :\r
+    m_impl(new CertificateSupportImplementation(widgetModel))\r
+{}\r
+\r
+CertificateSupport::~CertificateSupport()\r
+{}\r
+\r
+CertificateDB::CertificateDAO* CertificateSupport::\r
+    getCertificateDAO(void)\r
+{\r
+    return m_impl->getCertificateDAO();\r
+}\r
+\r
+Evas_Object* CertificateSupportUtil::createPopup(\r
+    Evas_Object* window,\r
+    const char* bodyText,\r
+    const char* checkText,\r
+    Evas_Smart_Cb\r
+    buttonCallback,\r
+    void* data)\r
+{\r
+    LogDebug("createPopup");\r
+    Evas_Object* popup = elm_popup_add(window);\r
+\r
+    Evas_Object* label = elm_label_add(popup);\r
+    elm_object_style_set(label, "popup/default");\r
+    elm_label_line_wrap_set(label, ELM_WRAP_MIXED);\r
+    elm_object_text_set(label, bodyText);\r
+    evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);\r
+    evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+    evas_object_show(label);\r
+\r
+    Evas_Object* layout = elm_layout_add(popup);\r
+    elm_layout_file_set(layout, DAEMON_EDJ_PATH, "popupWithCheck");\r
+    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
+\r
+    Evas_Object* check = elm_check_add(popup);\r
+    evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+    evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
+    evas_object_show(check);\r
+\r
+    elm_object_part_text_set(layout, "elm.text", checkText);\r
+    elm_object_part_content_set(layout, "elm.swallow.content", label);\r
+    elm_object_part_content_set(layout, "elm.swallow.end", check);\r
+\r
+    evas_object_show(layout);\r
+    elm_object_content_set(popup, layout);\r
+    Evas_Object* btn1 = elm_button_add(popup);\r
+    elm_object_text_set(btn1, "YES");\r
+    elm_object_part_content_set(popup, "button1", btn1);\r
+    evas_object_smart_callback_add(btn1, "clicked", buttonCallback, data);\r
+    Evas_Object* btn2 = elm_button_add(popup);\r
+    elm_object_text_set(btn2, "NO");\r
+    elm_object_part_content_set(popup, "button2", btn2);\r
+    evas_object_smart_callback_add(btn2, "clicked", buttonCallback, data);\r
+    return popup;\r
+}\r
+\r
+Evas_Object* CertificateSupportUtil::getPopup(Evas_Object* button)\r
+{\r
+    Assert(button);\r
+\r
+    Evas_Object* popup = button;\r
+    while (strcmp(elm_object_widget_type_get(popup), "elm_popup")) {\r
+        popup = elm_object_parent_widget_get(popup);\r
+        if (!popup) {\r
+            return NULL;\r
+        }\r
+    }\r
+    return popup;\r
+}\r
+\r
+Evas_Object* CertificateSupportUtil::getCheck(Evas_Object* popup)\r
+{\r
+    Assert(popup);\r
+    if (strcmp(elm_object_widget_type_get(popup), "elm_popup")) {\r
+        return NULL;\r
+    }\r
+    Evas_Object* check = elm_object_part_content_get(\r
+            elm_object_content_get(popup),\r
+            "elm.swallow.end");\r
+    return check;\r
+}\r
+\r
+CertificateDB::Result CertificateSupportUtil::getResult(\r
+    Evas_Object* button)\r
+{\r
+    using namespace CertificateDB;\r
+\r
+    Assert(button);\r
+    // get popup evas_object\r
+    Evas_Object* popup = getPopup(button);\r
+    if (popup == NULL) {\r
+        return RESULT_UNKNOWN;\r
+    }\r
+    bool allow = !strcmp("YES", elm_object_text_get(button));\r
+\r
+    // get check evas_object\r
+    Evas_Object* check = getCheck(popup);\r
+    if (check == NULL) {\r
+        return RESULT_UNKNOWN;\r
+    }\r
+    if (allow) {\r
+        return elm_check_state_get(check) ? RESULT_ALLOW_ALWAYS :\r
+               RESULT_ALLOW_ONCE;\r
+    } else {\r
+        return elm_check_state_get(check) ? RESULT_DENY_ALWAYS :\r
+               RESULT_DENY_ONCE;\r
+    }\r
+}\r
+} // namespace ViewModule\r
diff --git a/src/view/common/view_logic_certificate_support.h b/src/view/common/view_logic_certificate_support.h
new file mode 100755 (executable)
index 0000000..8216c9b
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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    view_logic_certificate_origin_support.h
+ * @author  Leerang Song (leerang.song@samsung.com)
+ * @version 1.0
+ * @brief   Header file for certificate
+ */
+
+#ifndef VIEW_LOGIC_CERTIFICATE_SUPPORT_H_
+#define VIEW_LOGIC_CERTIFICATE_SUPPORT_H_
+
+#include <memory>
+#include <Evas.h>
+#include <Elementary.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <wrt-commons/certificate-dao/certificate_dao.h>
+
+class WidgetModel;
+namespace CertificateDB {
+class CertificateDAO;
+}
+
+namespace ViewModule {
+class CertificateSupportImplementation;
+
+class CertificateSupport
+{
+  public:
+    CertificateSupport(WidgetModel* widgetModel);
+    virtual ~CertificateSupport();
+    CertificateDB::CertificateDAO* getCertificateDAO();
+
+  private:
+    std::unique_ptr<CertificateSupportImplementation> m_impl;
+};
+
+namespace CertificateSupportUtil {
+class PermissionData
+{
+  public:
+    CertificateDB::CertificateDAO* m_certiDao;
+    CertificateDB::CertificateData m_certiData;
+    void* m_data;
+
+    PermissionData(
+        CertificateDB::CertificateDAO* certiDao,
+        CertificateDB::CertificateData certiData,
+        void* data) :
+        m_certiDao(certiDao),
+        m_certiData(certiData),
+        m_data(data)
+    {}
+};
+
+Evas_Object* createPopup(Evas_Object* window,
+                         const char* bodyText,
+                         const char* checkText,
+                         Evas_Smart_Cb buttonCallback,
+                         void* data);
+Evas_Object* getPopup(Evas_Object* button);
+Evas_Object* getCheck(Evas_Object* popup);
+CertificateDB::Result getResult(Evas_Object* button);
+};
+} // namespace ViewModule
+
+#endif // VIEW_LOGIC_CERTIFICATE_SUPPORT_H_
\ No newline at end of file
index 3d573d8..58e9032 100644 (file)
@@ -33,8 +33,7 @@ const std::string LANGUAGE_EN = "en";
 
 namespace ViewModule {
 namespace CustomHeaderSupport {
-
-std::string getValueByField(const std::string field)
+std::string getValueByField(const std::string &field)
 {
     LogDebug("Field : " << field);
     std::string ret;
@@ -63,4 +62,4 @@ std::string getValueByField(const std::string field)
     return ret;
 }
 } // namespace CustomHeaderSupport
-} // namespace ViewModule
\ No newline at end of file
+} // namespace ViewModule
index 4e7c386..99ab3e9 100644 (file)
@@ -26,9 +26,9 @@
 
 namespace ViewModule {
 namespace CustomHeaderSupport {
-    const std::string ACCEPT_LANGUAGE = "Accept-Language";
+const std::string ACCEPT_LANGUAGE = "Accept-Language";
 
-    std::string getValueByField(const std::string field);
+std::string getValueByField(const std::string &field);
 } // namespace UserAgentSupport
 } // namespace CustomHeaderSupport
 
index 45475f6..0dad918 100644 (file)
@@ -35,27 +35,25 @@ const char * const GEOLOCATION_ASK_MSG =
 
 namespace ViewModule {
 namespace GeolocationSupport {
-
 bool askUserForPermission()
 {
     return Wrt::Popup::PopupInvoker().askYesNo(
-        GEOLOCATION_ASK_TITLE,
-        GEOLOCATION_ASK_MSG);
+               GEOLOCATION_ASK_TITLE,
+               GEOLOCATION_ASK_MSG);
 }
 
 bool checkRequestedStateOfGeolocationFeature(WrtDB::WidgetDAOReadOnlyPtr dao)
 {
     WrtDB::DbWidgetFeature geolocationFeature;
     geolocationFeature.name = DPL::FromASCIIString(
-        WrtDB::GlobalConfig::GetW3CGeolocationFeatureName() );
+            WrtDB::GlobalConfig::GetW3CGeolocationFeatureName() );
 
     auto features = dao->getFeaturesList();
 
     auto it = features.find(geolocationFeature);
 
-    if ( it != features.end() )
-    {
-        if(it->rejected){
+    if (it != features.end() ) {
+        if (it->rejected) {
             LogInfo("Feature rejected by ACE");
             return false;
         }
@@ -67,34 +65,31 @@ bool checkRequestedStateOfGeolocationFeature(WrtDB::WidgetDAOReadOnlyPtr dao)
 
 bool getLocalizationState(const DPL::String& tizenId, bool enableHighAccuracy)
 {
-    LogDebug ("Get localization state");
+    LogDebug("Get localization state");
 
     WrtDB::WidgetDAOReadOnlyPtr dao(new WrtDB::WidgetDAOReadOnly(tizenId));
 
-    if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP)
-    {
+    if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP) {
         return askUserForPermission();
     }
 
     return checkRequestedStateOfGeolocationFeature(dao) &&
-        ViewModule::SecuritySupport::geolocationACECheck(tizenId,
-            enableHighAccuracy);
+           ViewModule::SecuritySupport::geolocationACECheck(tizenId,
+                                                            enableHighAccuracy);
 }
 
 bool getGeolocationModuleState(const DPL::String& tizenId)
 {
-    LogDebug ("Get geolocation state");
+    LogDebug("Get geolocation state");
 
     WrtDB::WidgetDAOReadOnlyPtr dao(new WrtDB::WidgetDAOReadOnly(tizenId));
 
-    if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP)
-    {
+    if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP) {
         LogInfo("Geolocation enable for tizen app");
         return true;
     }
 
     return checkRequestedStateOfGeolocationFeature(dao);
 }
-
 } // namespace GeolocationSupport
 } // namespace ViewModule
index 3802223..c290058 100644 (file)
@@ -25,7 +25,6 @@
 
 namespace ViewModule {
 namespace GeolocationSupport {
-
 /*
  * @returns true if user allowed for share current position
  * @returns false otherwise
@@ -35,11 +34,12 @@ bool getLocalizationState(const DPL::String& tizenId, bool enableHighAccuracy);
 /*
  * The function returns requested state of geolocation module
  *
- * @returns true if geolocation module(navigator.geolocation object) should be enabled
- *          false if geolocation module(navigator.geolocation object) should be disabled
+ * @returns true if geolocation module(navigator.geolocation object) should be
+ * enabled
+ *          false if geolocation module(navigator.geolocation object) should be
+ * disabled
  */
 bool getGeolocationModuleState(const DPL::String& tizenId);
-
 }
 } // namespace ViewModule
 
index 1777fa2..95bad28 100644 (file)
 
 namespace ViewModule {
 namespace PasswordSupport {
-
 namespace {
 const char *SCHEME_TYPE_HTTP = "http";
 const char *SCHEME_TYPE_HTTPS = "https";
-const char *AUTOSAVEIDPASS_OFF          = "OFF";
-const char *AUTOSAVEIDPASS_ON           = "ON";
-const char *AUTOSAVEIDPASS_ALWAYS_ASK   = "ALWAYS_ASK";
+const char *AUTOSAVEIDPASS_OFF = "OFF";
+const char *AUTOSAVEIDPASS_ON = "ON";
+const char *AUTOSAVEIDPASS_ALWAYS_ASK = "ALWAYS_ASK";
 // This message isn't confirmed by UX guide
 // It should be change to use IDS for translate
 const char AUTOSAVE_ASK_MSG[] = "Do you want to remember the password on ";
@@ -88,7 +87,6 @@ Eina_Bool submitFormDataSet(const Eina_Hash* /*hash*/,
 
     return EINA_TRUE;
 }
-
 }
 
 void submitClicked(std::string uri, Eina_Hash* data)
@@ -199,7 +197,7 @@ DPL::Optional<DPL::String> jsForAutoFillData(const char *uri)
     FOREACH(iterator, submitData) {
         keyOstring << DOUBLE_QUOTES << iterator->key << DOUBLE_QUOTES;
         valueOstring << DOUBLE_QUOTES << iterator->value << DOUBLE_QUOTES;
-        if (*iterator !=  submitData.back()) {
+        if (*iterator != submitData.back()) {
             keyOstring << COMMA;
             valueOstring << COMMA;
         }
@@ -245,6 +243,5 @@ DPL::Optional<DPL::String> jsForAutoFillData(const char *uri)
 
     return DPL::FromUTF8String(jsStr);
 }
-
 } // namespaec PasswordSupport
 } // namespaec ViewModule
index 0f63c9f..aab681c 100644 (file)
 
 namespace ViewModule {
 namespace PasswordSupport {
-
 void submitClicked(std::string uri, Eina_Hash* data);
 DPL::Optional<DPL::String> jsForAutoFillData(const char *uri);
-
 } // namespace PasswordSupport
 } // namespace ViewModule
 
index bc2f8fa..48cac1e 100644 (file)
@@ -53,8 +53,7 @@ class SecurityOriginSupportImplementation
     }
 
     ~SecurityOriginSupportImplementation()
-    {
-    }
+    {}
 
     SecurityOriginDB::SecurityOriginDAO* getSecurityOriginDAO(void)
     {
@@ -63,7 +62,8 @@ class SecurityOriginSupportImplementation
             LogDebug("initialize securityOriginDAO");
             m_securityOriginDAO =
                 SecurityOriginDB::SecurityOriginDAOPtr(
-                    new SecurityOriginDB::SecurityOriginDAO(m_model->TizenId));
+                    new SecurityOriginDB::SecurityOriginDAO(m_model->TzPkgId.
+                                                                Get()));
             // initialize security result data. Remove allow, deny for
             m_securityOriginDAO->removeSecurityOriginData(
                 SecurityOriginDB::RESULT_ALLOW_ONCE);
@@ -80,16 +80,10 @@ class SecurityOriginSupportImplementation
         std::string key;
         if (feature == FEATURE_GEOLOCATION) {
             key = WrtDB::VconfConfig::GetVconfKeyGeolocationUsage(
-                m_model->TizenId);
+                    m_model->TizenId);
         } else if (feature == FEATURE_WEB_NOTIFICATION) {
             key = WrtDB::VconfConfig::GetVconfKeyWebNotificationUsage(
-                m_model->TizenId);
-        } else if (feature == FEATURE_WEB_DATABASE) {
-            key = WrtDB::VconfConfig::GetVconfKeyWebDatabaseUsage(
-                m_model->TizenId);
-        } else if (feature == FEATURE_FILE_SYSTEM_ACCESS) {
-            key = WrtDB::VconfConfig::GetVconfKeyFilesystemUsage(
-                m_model->TizenId);
+                    m_model->TizenId);
         } else {
             Assert("Wrong feature argument is input");
         }
@@ -105,14 +99,13 @@ class SecurityOriginSupportImplementation
 
 SecurityOriginSupport::SecurityOriginSupport(WidgetModel* widgetModel) :
     m_impl(new SecurityOriginSupportImplementation(widgetModel))
-{
-}
+{}
 
 SecurityOriginSupport::~SecurityOriginSupport()
-{
-}
+{}
 
-SecurityOriginDB::SecurityOriginDAO* SecurityOriginSupport::getSecurityOriginDAO(void)
+SecurityOriginDB::SecurityOriginDAO* SecurityOriginSupport::
+    getSecurityOriginDAO(void)
 {
     return m_impl->getSecurityOriginDAO();
 }
@@ -123,11 +116,13 @@ WrtDB::SettingsType SecurityOriginSupport::isNeedPermissionCheck(
     return m_impl->isNeedPermissionCheck(feature);
 }
 
-Evas_Object* SecurityOriginSupportUtil::createPopup(Evas_Object* window,
-                         const char* bodyText,
-                         const char* checkText,
-                         Evas_Smart_Cb buttonCallback,
-                         void* data)
+Evas_Object* SecurityOriginSupportUtil::createPopup(
+    Evas_Object* window,
+    const char* bodyText,
+    const char* checkText,
+    Evas_Smart_Cb
+    buttonCallback,
+    void* data)
 {
     LogDebug("createPopup");
     Evas_Object* popup = elm_popup_add(window);
@@ -156,11 +151,11 @@ Evas_Object* SecurityOriginSupportUtil::createPopup(Evas_Object* window,
     evas_object_show(layout);
     elm_object_content_set(popup, layout);
     Evas_Object* btn1 = elm_button_add(popup);
-    elm_object_text_set(btn1, "YES");
+    elm_object_text_set(btn1, "Allow");
     elm_object_part_content_set(popup, "button1", btn1);
     evas_object_smart_callback_add(btn1, "clicked", buttonCallback, data);
     Evas_Object* btn2 = elm_button_add(popup);
-    elm_object_text_set(btn2, "NO");
+    elm_object_text_set(btn2, "Deny");
     elm_object_part_content_set(popup, "button2", btn2);
     evas_object_smart_callback_add(btn2, "clicked", buttonCallback, data);
     return popup;
@@ -187,12 +182,13 @@ Evas_Object* SecurityOriginSupportUtil::getCheck(Evas_Object* popup)
         return NULL;
     }
     Evas_Object* check = elm_object_part_content_get(
-        elm_object_content_get(popup),
-        "elm.swallow.end");
+            elm_object_content_get(popup),
+            "elm.swallow.end");
     return check;
 }
 
-SecurityOriginDB::Result SecurityOriginSupportUtil::getResult(Evas_Object* button)
+SecurityOriginDB::Result SecurityOriginSupportUtil::getResult(
+    Evas_Object* button)
 {
     using namespace SecurityOriginDB;
 
@@ -202,7 +198,7 @@ SecurityOriginDB::Result SecurityOriginSupportUtil::getResult(Evas_Object* butto
     if (popup == NULL) {
         return RESULT_UNKNOWN;
     }
-    bool allow = !strcmp("YES", elm_object_text_get(button));
+    bool allow = !strcmp("Allow", elm_object_text_get(button));
 
     // get check evas_object
     Evas_Object* check = getCheck(popup);
@@ -210,9 +206,11 @@ SecurityOriginDB::Result SecurityOriginSupportUtil::getResult(Evas_Object* butto
         return RESULT_UNKNOWN;
     }
     if (allow) {
-        return elm_check_state_get(check) ? RESULT_ALLOW_ALWAYS : RESULT_ALLOW_ONCE;
+        return elm_check_state_get(check) ? RESULT_ALLOW_ALWAYS :
+               RESULT_ALLOW_ONCE;
     } else {
-        return elm_check_state_get(check) ? RESULT_DENY_ALWAYS : RESULT_DENY_ONCE;
+        return elm_check_state_get(check) ? RESULT_DENY_ALWAYS :
+               RESULT_DENY_ONCE;
     }
 }
 } // namespace ViewModule
index f7fadc0..2563aec 100644 (file)
 
 class WidgetModel;
 namespace SecurityOriginDB {
-    class SecurityOriginDAO;
+class SecurityOriginDAO;
 }
 
 namespace ViewModule {
-
 class SecurityOriginSupportImplementation;
 
 class SecurityOriginSupport
@@ -63,11 +62,10 @@ class PermissionData
         SecurityOriginDB::SecurityOriginDAO* originDao,
         SecurityOriginDB::SecurityOriginData originData,
         void* data) :
-            m_originDao(originDao),
-            m_originData(originData),
-            m_data(data)
-    {
-    };
+        m_originDao(originDao),
+        m_originData(originData),
+        m_data(data)
+    {}
 };
 
 Evas_Object* createPopup(Evas_Object* window,
@@ -81,5 +79,4 @@ SecurityOriginDB::Result getResult(Evas_Object* button);
 };
 } // namespace ViewModule
 
-
 #endif // VIEW_LOGIC_SECURITY_ORIGIN_SUPPORT_H_
index 0ea1df0..1c689d0 100644 (file)
@@ -31,9 +31,7 @@
 
 namespace ViewModule {
 namespace SecuritySupport {
-
 namespace {
-
 const char *GEOLOCATION_DEV_CAP = "geolocation.position";
 const char *GEOLOCATION_PARAM_NAME = "param:enableHighAccuracy";
 const char *GEOLOCATION_PARAM_VALUE = "true";
@@ -71,12 +69,11 @@ bool simpleAceCheck(
 
     LogDebug("Result is: " << static_cast<int>(result));
 
-    delete [] aceRequest.dev_cap_list.items[0].param_list.items;
-    delete [] aceRequest.dev_cap_list.items;
+    delete[] aceRequest.dev_cap_list.items[0].param_list.items;
+    delete[] aceRequest.dev_cap_list.items;
 
     return ACE_OK == ret && ACE_TRUE == result;
 }
-
 } //TODO copied from view_logic.cpp
 
 bool checkWhitelist(const char *url)
@@ -92,7 +89,8 @@ bool checkWhitelist(const char *url)
     return whiteURIList.isRequiredIRI(DPL::FromUTF8String(std::string(url)));
 }
 
-bool geolocationACECheck(const DPL::String& tizenId, bool highAccuracy) {
+bool geolocationACECheck(const DPL::String& tizenId, bool highAccuracy)
+{
     const char *paramName = NULL;
     const char *paramValue = NULL;
     if (highAccuracy) {
@@ -100,11 +98,10 @@ bool geolocationACECheck(const DPL::String& tizenId, bool highAccuracy) {
         paramValue = GEOLOCATION_PARAM_VALUE;
     }
     return simpleAceCheck(
-        tizenId,
-        GEOLOCATION_DEV_CAP,
-        paramName,
-        paramValue);
+               tizenId,
+               GEOLOCATION_DEV_CAP,
+               paramName,
+               paramValue);
 }
-
 } // namespace SecuritySupport
 } //namespace ViewModule
index 215b207..364c5d5 100644 (file)
@@ -30,12 +30,10 @@ class WidgetModel;
 
 namespace ViewModule {
 namespace SecuritySupport {
-
 char const * const PARAM_URL = "param:url";
 
 bool checkWhitelist(const char *url);
 bool geolocationACECheck(const DPL::String& tizenId, bool highAccuracy);
-
 } // namespace SecuritySupport
 } // namespace ViewModule
 
index e4fc832..258c637 100644 (file)
 
 namespace ViewModule {
 namespace StorageSupport {
-
-namespace
-{ //anonymous
-    const mode_t TEMPORARY_STORAGE_MODE = 0700;
+namespace { //anonymous
+const mode_t TEMPORARY_STORAGE_MODE = 0700;
 }
 
 void initializeStorage(WidgetModel *widgetModel)
@@ -43,10 +41,10 @@ void initializeStorage(WidgetModel *widgetModel)
 
     // create temporary storage
     std::string path =
-            DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
-    if(!WrtUtilMakeDir(path, TEMPORARY_STORAGE_MODE)){
+        DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
+    if (!WrtUtilMakeDir(path, TEMPORARY_STORAGE_MODE)) {
         ThrowMsg(DPL::CommonException::InternalError,
-                   "Fail to initialize temporary storage");
+                 "Fail to initialize temporary storage");
     }
 }
 
@@ -57,12 +55,11 @@ void deinitializeStorage(WidgetModel *widgetModel)
 
     // remove temporary storage
     std::string path =
-            DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
-    if(!WrtUtilRemove(path)){
+        DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
+    if (!WrtUtilRemove(path)) {
         ThrowMsg(DPL::CommonException::InternalError,
-                   "Fail to deinitialize temporary storage");
+                 "Fail to deinitialize temporary storage");
     }
 }
-
 } // namespace StorageSupport
 } // namespace ViewModule
index 742b2b4..c7c9eb1 100644 (file)
@@ -27,10 +27,8 @@ class WidgetModel;
 
 namespace ViewModule {
 namespace StorageSupport {
-
 void initializeStorage(WidgetModel *widgetModel);
 void deinitializeStorage(WidgetModel *widgetModel);
-
 } // namespace StorageSupport
 } // namespace ViewModule
 
index d3d7d44..b636eea 100644 (file)
 #include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
 #include <wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h>
 #include <stdio.h>
+#include <pcrecpp.h>
 
 namespace ViewModule {
 namespace UriSupport {
-
 namespace {
 enum ServiceDataType
 {
     SERVICE_DATA_TYPE_OPERATION,
     SERVICE_DATA_TYPE_URI,
-    SERVICE_DATA_TYPE_MIME,
-    SERVICE_DATA_TYPE_MIME_ELEMENT
+    SERVICE_DATA_TYPE_URI_SCHEME,
+    SERVICE_DATA_TYPE_MIME
 };
 
 char const * const SCHEME_TYPE_FILE = "file";
 char const * const SCHEME_TYPE_WIDGET = "widget";
-char const * const SERVICE_DATA_WILD_CHAR = "*";
-char const * const SERVICE_DATA_MIME_TOKEN = "/";
-const unsigned int SIZE_OF_MIME_ELEMENT = 2;
-
-std::list<std::string> parsingMimeData(std::string origin, std::string token)
-{
-    std::list<std::string> parsedData;
-    size_t current = 0;
-    size_t next = 0;
-    do {
-        next = origin.find_first_of(token, current);
-        parsedData.push_back(origin.substr(current, next - current));
-        current = next + 1;
-    } while (next != std::string::npos && current < origin.length());
-    return parsedData;
-}
 
 /**
  * Parses scheme from appsvc. From mailto:test@wacapps.net
@@ -78,52 +62,58 @@ std::vector<std::string> parseScheme(const std::string &scheme)
     if (pos != std::string::npos) {
         schemeParts.push_back(scheme.substr(0, pos));
         schemeParts.push_back(
-                scheme.substr(pos + 1, scheme.length() - pos - 1));
+            scheme.substr(pos + 1, scheme.length() - pos - 1));
     }
     return schemeParts;
 }
 
+bool wildcardCompare(std::string wildcardString, std::string target)
+{
+    std::string re = wildcardString;
+
+    // replace special character to meaning character
+    pcrecpp::RE("\\\\").GlobalReplace("\\\\\\\\", &re);
+    pcrecpp::RE("\\.").GlobalReplace("\\\\.", &re);
+    pcrecpp::RE("\\+").GlobalReplace("\\\\+", &re);
+    pcrecpp::RE("\\?").GlobalReplace("\\\\?", &re);
+    pcrecpp::RE("\\^").GlobalReplace("\\\\^", &re);
+    pcrecpp::RE("\\$").GlobalReplace("\\\\$", &re);
+    pcrecpp::RE("\\[").GlobalReplace("\\\\[", &re);
+    pcrecpp::RE("\\]").GlobalReplace("\\\\]", &re);
+    pcrecpp::RE("\\{").GlobalReplace("\\\\{", &re);
+    pcrecpp::RE("\\}").GlobalReplace("\\\\}", &re);
+    pcrecpp::RE("\\(").GlobalReplace("\\\\(", &re);
+    pcrecpp::RE("\\)").GlobalReplace("\\\\)", &re);
+    pcrecpp::RE("\\|").GlobalReplace("\\\\|", &re);
+
+    // replace wildcard character to regex type
+    pcrecpp::RE("\\\*").GlobalReplace(".*", &re);
+
+    return pcrecpp::RE(re).FullMatch(target);
+}
+
 bool compareServiceData(ServiceDataType type,
                         std::string origin,
                         std::string other)
 {
-    if (SERVICE_DATA_TYPE_OPERATION == type) {
+    if (SERVICE_DATA_TYPE_OPERATION == type)
+    {
         return origin == other;
-    } else if (SERVICE_DATA_TYPE_URI == type
-               || SERVICE_DATA_TYPE_MIME_ELEMENT == type)
+    }
+    else if (SERVICE_DATA_TYPE_URI == type)
+    {
+        return wildcardCompare(origin, other);
+    }
+    else if (SERVICE_DATA_TYPE_URI_SCHEME == type)
+    {
+        return origin == other;
+    }
+    else if (SERVICE_DATA_TYPE_MIME == type)
+    {
+        return wildcardCompare(origin, other);
+    }
+    else
     {
-        if (SERVICE_DATA_WILD_CHAR == origin) {
-            return true;
-        } else {
-            return origin == other;
-        }
-    } else if (SERVICE_DATA_TYPE_MIME == type) {
-        if (other == "") {
-            return origin == other;
-        }
-
-        std::list<std::string> vectorOrigin =
-            parsingMimeData(origin, SERVICE_DATA_MIME_TOKEN);
-        if (SIZE_OF_MIME_ELEMENT != vectorOrigin.size()) {
-            return false;
-        }
-        std::list<std::string> vectorOther =
-            parsingMimeData(other, SERVICE_DATA_MIME_TOKEN);
-        if (SIZE_OF_MIME_ELEMENT != vectorOther.size()) {
-            return false;
-        }
-
-        FOREACH(it, vectorOrigin) {
-            if (!compareServiceData(SERVICE_DATA_TYPE_MIME_ELEMENT,
-                                    *it,
-                                    vectorOther.front()))
-            {
-                return false;
-            }
-            vectorOther.pop_front();
-        }
-        return true;
-    } else {
         LogError("Wrong data type");
         return false;
     }
@@ -144,46 +134,46 @@ std::string prepareUrl(const std::string &url, const std::string &insert)
 }
 
 std::string getCustomHandlerProtocolUri(
-        WidgetModel *widgetModel,
-        const std::string &schemeType,
-        const std::string &schemeValue)
+    WidgetModel *widgetModel,
+    const std::string &schemeType,
+    const std::string &schemeValue)
 {
     CustomHandlerDB::Interface::attachDatabaseRO();
     CustomHandlerDB::CustomHandlerDAOReadOnly handlersDao(widgetModel->TizenId);
     CustomHandlerDB::CustomHandlerPtr handler =
-            handlersDao.getActivProtocolHandler(
-                DPL::FromASCIIString(schemeType));
+        handlersDao.getActivProtocolHandler(
+            DPL::FromASCIIString(schemeType));
     CustomHandlerDB::Interface::detachDatabase();
     if (handler) {
         LogDebug("Found handler, url: " << handler->url);
         return prepareUrl(DPL::ToUTF8String(handler->base_url) +
-                DPL::ToUTF8String(handler->url), schemeValue);
+                          DPL::ToUTF8String(handler->url), schemeValue);
     }
     return "";
 }
 
 std::string getCustomHandlerContentUri(
-        WidgetModel *widgetModel,
-        const std::string &mime,
-        const std::string &mimeValue)
+    WidgetModel *widgetModel,
+    const std::string &mime,
+    const std::string &mimeValue)
 {
     CustomHandlerDB::Interface::attachDatabaseRO();
     CustomHandlerDB::CustomHandlerDAOReadOnly handlersDao(widgetModel->TizenId);
     CustomHandlerDB::CustomHandlerPtr handler =
-            handlersDao.getActivContentHandler(
-                DPL::FromASCIIString(mime));
+        handlersDao.getActivContentHandler(
+            DPL::FromASCIIString(mime));
     CustomHandlerDB::Interface::detachDatabase();
     if (handler) {
         LogDebug("Found handler, url: " << handler->url);
         return prepareUrl(DPL::ToUTF8String(handler->base_url) +
-                DPL::ToUTF8String(handler->url), mimeValue);
+                          DPL::ToUTF8String(handler->url), mimeValue);
     }
     return "";
 }
 
 std::string getAppServiceUri(bundle *bundle, WidgetModel *widgetModel)
 {
-    if(!bundle)
+    if (!bundle)
     {
         LogError("Bundle is empty");
         return std::string("");
@@ -192,43 +182,63 @@ std::string getAppServiceUri(bundle *bundle, WidgetModel *widgetModel)
     const char* value = NULL;
     value = appsvc_get_operation(bundle);
     std::string operation = value ? value : "";
-    value = appsvc_get_uri(bundle);
-    std::string scheme = value ? value : "";
+
     value = appsvc_get_mime(bundle);
     std::string mime = value ? value : "";
 
-    LogDebug("operation : " << operation);
-    LogDebug("schemeType : " << scheme);
-    LogDebug("mimetype : " << mime);
-
-    WidgetApplicationServiceList appServiceList =
-        widgetModel->AppServiceList.Get();
-    FOREACH(appServiceIt, appServiceList) {
-        if (compareServiceData(SERVICE_DATA_TYPE_OPERATION,
-                               DPL::ToUTF8String(appServiceIt->operation),
-                               operation) &&
-            compareServiceData(SERVICE_DATA_TYPE_URI,
-                               DPL::ToUTF8String(appServiceIt->scheme),
-                               scheme) &&
-            compareServiceData(SERVICE_DATA_TYPE_MIME,
-                               DPL::ToUTF8String(appServiceIt->mime),
-                               mime))
+    value = appsvc_get_uri(bundle);
+    std::string uri = value ? value : "";
+
+    std::vector<std::string> schemeParts = parseScheme(uri);
+    std::string scheme = (schemeParts.empty()) ? "" : schemeParts[0];
+
+    std::string ignoreScheme = "file";
+    if (scheme == ignoreScheme)
+    {
+        LogInfo("exception : 'file' scheme is ignored.");
+        uri = "";
+        scheme = "";
+    }
+
+    LogDebug("AppService Information");
+    LogDebug(" - operation : " << operation);
+    LogDebug(" - uri : " << uri);
+    LogDebug(" - scheme : " << scheme);
+    LogDebug(" - mimetype : " << mime);
+
+    WidgetApplicationServiceList appServiceList = widgetModel->AppServiceList.Get();
+
+    FOREACH(appServiceIt, appServiceList)
+    {
+        if (compareServiceData(SERVICE_DATA_TYPE_OPERATION, DPL::ToUTF8String(appServiceIt->operation), operation))
         {
-            return DPL::ToUTF8String(appServiceIt->src);
+            if (compareServiceData(SERVICE_DATA_TYPE_URI_SCHEME, DPL::ToUTF8String(appServiceIt->scheme), scheme) ||
+                compareServiceData(SERVICE_DATA_TYPE_URI, DPL::ToUTF8String(appServiceIt->scheme), uri) )
+            {
+                if (compareServiceData(SERVICE_DATA_TYPE_MIME, DPL::ToUTF8String(appServiceIt->mime), mime))
+                {
+                    LogDebug("AppService Matched with : " << appServiceIt->src);
+                    LogDebug(" - operation : " << appServiceIt->operation);
+                    LogDebug(" - uri : " << appServiceIt->scheme);
+                    LogDebug(" - mimetype : " << appServiceIt->mime);
+
+                    return DPL::ToUTF8String(appServiceIt->src);
+                }
+            }
         }
     }
-    std::vector<std::string> schemeParts = parseScheme(scheme);
+
     if (schemeParts.size() > 1) {
         LogDebug("Scheme parts: " << schemeParts[0] << ", " << schemeParts[1]);
         return getCustomHandlerProtocolUri(
-                widgetModel, schemeParts[0], schemeParts[1]);
+                   widgetModel, schemeParts[0], schemeParts[1]);
     }
     if (mime != "") {
         value = appsvc_get_data(bundle, APPSVC_DATA_SELECTED);
         if (value != NULL) {
             LogDebug("Use mime type for: " << value);
             return getCustomHandlerContentUri(
-                    widgetModel, mime, std::string(value));
+                       widgetModel, mime, std::string(value));
         } else {
             LogError("Selected file for mime is null, nothind to do");
         }
@@ -258,11 +268,12 @@ std::string getUri(WidgetModel *widgetModel, const std::string &defaultUri)
     std::string preFix = DPL::ToUTF8String(widgetModel->PrefixURL.Get());
 
     if (strstr(startUri.c_str(), "http") == startUri.c_str() ||
-            strstr( startUri.c_str(), preFix.c_str()) == startUri.c_str()) {
+        strstr(startUri.c_str(), preFix.c_str()) == startUri.c_str())
+    {
         uri = DPL::FromUTF8String(startUri);
     } else {
         uri = widgetModel->PrefixURL.Get() +
-        DPL::FromUTF8String(startUri);
+            DPL::FromUTF8String(startUri);
     }
     return DPL::ToUTF8String(uri).c_str();
 }
@@ -304,6 +315,5 @@ DPL::OptionalString localizeURI(const DPL::String& inputURI,
         return DPL::OptionalString(uri);
     }
 }
-
 } // namespace UriSupportImplementation
 } // namespace ViewModule
index e6b7090..d1dc00e 100644 (file)
@@ -31,12 +31,10 @@ class WidgetModel;
 
 namespace ViewModule {
 namespace UriSupport {
-
 std::string getUri(WidgetModel *widgetModel, const std::string &defaultUri);
 
 DPL::OptionalString localizeURI(const DPL::String& inputURI,
                                 const WidgetModel* model);
-
 } // namespace UriSupport
 } // namespace ViewModule
 
index 0f3883e..0e0a05d 100644 (file)
@@ -36,7 +36,6 @@ const std::string SYSTEM_USER_AGENT = "System user agent";
 
 namespace ViewModule {
 namespace UserAgentSupport {
-
 std::string getUserAgentFromVconf()
 {
     using namespace WrtDB;
@@ -68,7 +67,8 @@ std::string getUserAgentFromVconf()
         }
     } else {
         DPL::String value =
-            GlobalDAOReadOnly::GetUserAgentValue(DPL::FromUTF8String(userAgentName));
+            GlobalDAOReadOnly::GetUserAgentValue(DPL::FromUTF8String(
+                                                     userAgentName));
         userAgent = DPL::ToUTF8String(value);
         LogDebug("value : " << value);
     }
index c37e2e9..c166ecf 100644 (file)
@@ -26,7 +26,7 @@
 
 namespace ViewModule {
 namespace UserAgentSupport {
-    std::string getUserAgentFromVconf();
+std::string getUserAgentFromVconf();
 } // namespace UserAgentSupport
 } // namespace ViewModule
 
index 8c90818..2185368 100644 (file)
 #include <haptic.h>
 
 namespace ViewModule {
-
-VibrationSupport::VibrationSupport(): m_initialized(false),
-                                             m_handle(NULL),
-                                             m_effect_handle(NULL)
-{
-}
+VibrationSupport::VibrationSupport() : m_initialized(false),
+    m_handle(NULL),
+    m_effect_handle(NULL)
+{}
 
 VibrationSupport::~VibrationSupport()
 {
@@ -45,17 +43,13 @@ void VibrationSupport::deinitialize(void)
 {
     LogDebug("deinitialize");
 
-    if( m_initialized )
-    {
+    if (m_initialized) {
         int ret = haptic_close(m_handle);
 
-        if( HAPTIC_ERROR_NONE == ret )
-        {
+        if (HAPTIC_ERROR_NONE == ret) {
             m_initialized = false;
             LogDebug("deinitialize success");
-        }
-        else
-        {
+        } else {
             m_initialized = true;
             LogDebug("deinitialize failed - error code : " << ret);
         }
@@ -66,10 +60,8 @@ void VibrationSupport::startVibration(const long vibrationTime)
 {
     LogDebug("startVibration called");
 
-    if ( m_initialized == false )
-    {
-        if ( initializeVibration() == false )
-        {
+    if (m_initialized == false) {
+        if (initializeVibration() == false) {
             return;
         }
     }
@@ -77,12 +69,9 @@ void VibrationSupport::startVibration(const long vibrationTime)
     int time = static_cast<int>(vibrationTime);
     int ret = haptic_vibrate_monotone(m_handle, time, &m_effect_handle);
 
-    if( HAPTIC_ERROR_NONE == ret )
-    {
+    if (HAPTIC_ERROR_NONE == ret) {
         LogDebug("haptic_vibrate_monotone success");
-    }
-    else
-    {
+    } else {
         LogDebug("haptic_vibrate_monotone failed - error code : " << ret);
     }
 
@@ -92,19 +81,15 @@ void VibrationSupport::startVibration(const long vibrationTime)
 void VibrationSupport::stopVibration(void)
 {
     LogDebug("stopVibration called");
-    if ( m_initialized == false )
-    {
+    if (m_initialized == false) {
         return;
     }
 
     int ret = haptic_stop_all_effects(m_handle);
 
-    if( HAPTIC_ERROR_NONE == ret )
-    {
+    if (HAPTIC_ERROR_NONE == ret) {
         LogDebug("haptic_stop_all_effects success");
-    }
-    else
-    {
+    } else {
         LogDebug("haptic_stop_all_effects failed - error code : " << ret);
     }
 
@@ -115,20 +100,15 @@ bool VibrationSupport::initializeVibration(void)
 {
     LogDebug("initializeVibration called");
 
-
-    if ( m_initialized == false )
-    {
+    if (m_initialized == false) {
         haptic_device_h handle = NULL;
         int ret = haptic_open(HAPTIC_DEVICE_0, &handle);
 
-        if ( ret == HAPTIC_ERROR_NONE )
-        {
+        if (ret == HAPTIC_ERROR_NONE) {
             LogDebug("initializeVibration success");
             m_initialized = true;
             m_handle = handle;
-        }
-        else
-        {
+        } else {
             LogDebug("initializeVibration failed - error code : " << ret);
             m_initialized = false;
             m_handle = NULL;
@@ -137,5 +117,4 @@ bool VibrationSupport::initializeVibration(void)
 
     return m_initialized;
 }
-
 } // namespace ViewModule
index 642288d..a9d248c 100644 (file)
@@ -24,7 +24,6 @@
 #include <haptic.h>
 
 namespace ViewModule {
-
 class VibrationSupport
 {
   public:
@@ -43,7 +42,6 @@ class VibrationSupport
 
     bool initializeVibration(void);
 };
-
 } // namespace ViewModule
 
 #endif // VIEW_LOGIC_VIBRATION_SUPPORT_H_
old mode 100755 (executable)
new mode 100644 (file)
index e24da45..695140a
 #include <string>
 #include <common/evas_object.h>
 #include <EWebKit2.h>
-#include <i_runnable_widget_object.h>
+#include <user_delegates.h>
 
 class WidgetModel; //FORWARD DECLARATION
 namespace ViewModule {
-
 /** \brief Interface to ViewModule. Object of IViewModule type is returned from
  *  ViewModuleMgr factory.
  */
 class IViewModule
 {
-public:
+  public:
     virtual bool createWebView(Ewk_Context* context,
                                Evas_Object* window) = 0;
-    virtual void destroyWebView() = 0;
-    virtual void initialize() = 0;
-    virtual void terminate() = 0;
     virtual void prepareView(WidgetModel *, const std::string &) = 0;
     virtual void showWidget() = 0;
     virtual void hideWidget() = 0;
-    virtual void changeViewVisibility(bool isVisible) = 0;
-    virtual void suspendWidget()= 0;
+    virtual void suspendWidget() = 0;
     virtual void resumeWidget() = 0;
     virtual void resetWidget() = 0;
     virtual void backward() = 0;
@@ -55,6 +50,12 @@ public:
     virtual Evas_Object* getCurrentWebview() = 0;
     virtual void fireJavascriptEvent(int event, void* data) = 0;
     virtual void setUserCallbacks(const WRT::UserDelegatesPtr& cbs) = 0;
+    virtual void checkSyncMessageFromBundle(
+            const char* name,
+            const char* body,
+            char** returnData) = 0;
+    virtual void downloadData(const char* url) = 0;
+    virtual void activateVibration(bool on, uint64_t time) = 0;
 };
 
 typedef std::shared_ptr<IViewModule> IViewModulePtr;
@@ -64,7 +65,6 @@ typedef std::shared_ptr<IViewModule> IViewModulePtr;
  * to IViewModule object.
  */
 IViewModulePtr createView();
-
 } //namespace
 
 #endif /* WRT_SRC_VIEW_I_VIEW_MODULE_H_ */
index 2b9d00a..79f1993 100644 (file)
 #include "i_view_module.h"
 #include <view_logic.h>
 
-namespace ViewModule
-{
-
+namespace ViewModule {
 IViewModulePtr createView()
 {
     IViewModulePtr ptr(new ViewLogic());
     return ptr;
 }
-
 } //namespace
index 2e3d3c7..811c49e 100644 (file)
@@ -31,6 +31,7 @@ PKG_CHECK_MODULES(VIEW_MODULE_DEP
     security-core
     security-client
     haptic
+    sysman
     REQUIRED
 )
 
@@ -43,13 +44,13 @@ PKG_CHECK_MODULES(SYS_VIEW_MODULE_DEP
 
 SET(VIEW_MODULE_SOURCES
     ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic.cpp
-    ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_filesystem_support.cpp
+    ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_authentication_challenge_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_scheme_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_geolocation_support_webkit2.cpp
     ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_usermedia_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_web_notification_support.cpp
-    ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_web_storage_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/webkit/bundles/plugin_module_support.cpp
+    ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_certificate_confirm_support.cpp
     ${VIEW_MODULE_SOURCES}
 )
 
index beb0a14..2069856 100644 (file)
@@ -27,6 +27,7 @@ PKG_CHECK_MODULES(BUNDLES_DEP
     dpl-encryption
     ewebkit2
     vconf
+    osp-appfw
     REQUIRED
 )
 
@@ -56,6 +57,9 @@ TARGET_LINK_LIBRARIES(${TARGET_BUNDLES_LIB}
     ${PROF_LIB}
 )
 
+# for encryption
+TARGET_LINK_LIBRARIES(${TARGET_BUNDLES_LIB} -L/usr/lib/osp -losp-appfw)
+
 SET_TARGET_PROPERTIES(${TARGET_BUNDLES_LIB} PROPERTIES
     VERSION ${PROJECT_VERSION}
     SOVERSION ${PROJECT_API_VERSION})
index 1d34020..9a9792e 100644 (file)
 #include <WKType.h>
 
 namespace {
-
 char const * const SCHEME_TYPE_FILE = "file";
 char const * const SCHEME_TYPE_WIDGET = "widget";
 char const * const WARP_ERROR_MSG =
-        "file:///usr/etc/wrt/warp_security_error.msg";
+    "file:///usr/etc/wrt/warp_security_error.msg";
 char const * const PARAM_URL = "param:url";
 char const * const ACE_IGNORED_SCHEMA[] = { "file://", "widget://", "data:",
-    "tel:", "sms:", "mmsto:", "mailto:", 0 };
-
-WKStringRef block_message = WKStringCreateWithUTF8CString("uri_block_msg");
-
+                                            "tel:", "sms:", "mmsto:", "mailto:",
+                                            0 };
 
 bool checkWARP(const char *url, const DPL::String& tizenId)
 {
@@ -69,7 +66,7 @@ bool checkWARP(const char *url, const DPL::String& tizenId)
     dao.getWidgetAccessInfo(widgetAccessInfoList);
 
     return (static_cast<WidgetAccessList>(widgetAccessInfoList)).isRequiredIRI(
-            DPL::FromUTF8String(std::string(url)));
+               DPL::FromUTF8String(std::string(url)));
 }
 
 bool checkACE(const char* url, bool xhr, const DPL::String& tizenId)
@@ -101,19 +98,18 @@ bool checkACE(const char* url, bool xhr, const DPL::String& tizenId)
 
     if (xhr) {
         aceRequest.dev_cap_list.items[0].name =
-                const_cast<ace_string_t>(devCapNamesXHR);
+            const_cast<ace_string_t>(devCapNamesXHR);
     } else {
         aceRequest.dev_cap_list.items[0].name =
-                const_cast<ace_string_t>(devCapNamesMarkup);
+            const_cast<ace_string_t>(devCapNamesMarkup);
     }
 
     aceRequest.dev_cap_list.items[0].param_list.count = 1;
     aceRequest.dev_cap_list.items[0].param_list.items = new ace_param_t[1];
     aceRequest.dev_cap_list.items[0].param_list.items[0].name =
-            const_cast<ace_string_t>(PARAM_URL);
+        const_cast<ace_string_t>(PARAM_URL);
     aceRequest.dev_cap_list.items[0].param_list.items[0].value =
-            const_cast<ace_string_t>(url);
-
+        const_cast<ace_string_t>(url);
 
     ace_bool_t result = ACE_FALSE;
 
@@ -123,31 +119,27 @@ bool checkACE(const char* url, bool xhr, const DPL::String& tizenId)
 
     LogDebug("Result is: " << static_cast<int>(result));
 
-    delete [] aceRequest.dev_cap_list.items[0].param_list.items;
-    delete [] aceRequest.dev_cap_list.items;
+    delete[] aceRequest.dev_cap_list.items[0].param_list.items;
+    delete[] aceRequest.dev_cap_list.items;
 
     return ACE_OK == ret && ACE_TRUE == result;
 }
 
-
 bool filterURIBySecurity(DPL::OptionalString &op_uri,
-         bool is_xhr,
-         const DPL::String& tizenId)
+                         bool is_xhr,
+                         const DPL::String& tizenId)
 {
-    if (!op_uri)
-    {
+    if (!op_uri) {
         return true; //accept empty uri
     }
 
     auto uri = DPL::ToUTF8String(*op_uri);
-    if (!checkWARP(uri.c_str(), tizenId))
-    {
+    if (!checkWARP(uri.c_str(), tizenId)) {
         LogDebug("Request was blocked by WARP: " << uri);
         return false;
     }
 
-    if (!checkACE(uri.c_str(), is_xhr, tizenId))
-    {
+    if (!checkACE(uri.c_str(), is_xhr, tizenId)) {
         LogDebug("Request was blocked by ACE: " << uri);
         return false;
     }
@@ -157,38 +149,27 @@ bool filterURIBySecurity(DPL::OptionalString &op_uri,
 } // namespace (anonymous)
 
 namespace BundleURIHandling {
-
-DPL::Optional<DPL::String> processURI(const DPL::String& inputURI,
-        bool is_xhr, const DPL::String& tizenId, WKBundleRef bundle)
+bool processURI(const DPL::String& inputURI,
+                bool is_xhr,
+                const DPL::String& tizenId,
+                WKBundleRef /*bundle*/)
 {
-    DPL::Optional<DPL::String> uri = localizeURI(inputURI, tizenId);
-
-    if (uri.IsNull())
-    {
+    DPL::Optional<DPL::String> uri(inputURI);
+    if (uri.IsNull()) {
         LogDebug("uri is empty");
-        return uri;
+        return true;
     }
 
     // check ACE, WARP
-    if (!filterURIBySecurity(uri, is_xhr, tizenId))
-    {
-        WKStringRef urlStr = WKStringCreateWithUTF8CString(
-                DPL::ToUTF8String(*uri).c_str());
-        WKTypeRef retVal = NULL;
-        // Send information about blocked URI to view_logic
-        LogInfo("Sent blocked uri to open browser later : " << uri);
-        WKBundlePostSynchronousMessage(bundle, block_message,
-                urlStr, &retVal);
-        WKRelease(urlStr);
-        WKRelease(retVal);
-        return DPL::Optional<DPL::String>::Null;
+    if (!filterURIBySecurity(uri, is_xhr, tizenId)) {
+        return false;
     }
 
-    return uri;
+    return true;
 }
 
 DPL::OptionalString localizeURI(const DPL::String& inputURI,
-        const DPL::String& tizenId)
+                                const DPL::String& tizenId)
 {
     auto uri = DPL::ToUTF8String(inputURI);
     LogDebug("localizing url: " << uri);
@@ -224,5 +205,4 @@ DPL::OptionalString localizeURI(const DPL::String& inputURI,
         return DPL::OptionalString(uri);
     }
 }
-
 } // namespace BundleURIHandling
index 75e3428..78b74cd 100644 (file)
 #include <WKBundle.h>
 
 namespace BundleURIHandling {
-    DPL::Optional<DPL::String> processURI(const DPL::String& inputURI,
-            bool is_xhr, const DPL::String& tizenId, WKBundleRef bundle);
-    DPL::OptionalString localizeURI(const DPL::String& inputURI,
-            const DPL::String& tizenId);
+bool processURI(const DPL::String& inputURI,
+                bool is_xhr,
+                const DPL::String& tizenId,
+                WKBundleRef bundle);
+DPL::OptionalString localizeURI(const DPL::String& inputURI,
+                                const DPL::String& tizenId);
 }
 
-
 #endif /* BUNDLE_URI_HANDLING_H_ */
index 2847e84..ab2a755 100644 (file)
@@ -25,10 +25,6 @@ const char * const INIT = "PluginModule::init";
 
 const char * const START = "PluginModule::start";
 const char * const SHUTDOWN = "PluginModule::shutdown";
-
-const char * const SUSPEND = "PluginModule::suspend";
-const char * const RESUME = "PluginModule::resume";
-
 const char * const SET_CUSTOM_PROPERTIES =
     "PluginModule::setCustomProperties";
 const char * const DISPATCH_JAVASCRIPT_EVENT =
index 1c56cb8..138baea 100644 (file)
@@ -28,7 +28,6 @@
 #include <js_overlay_types.h>
 
 namespace PluginModuleSupport {
-
 void init(Ewk_Context* ewkContext, const std::string& tizenId)
 {
     const char* name = BundleMessages::INIT;
@@ -51,21 +50,15 @@ void start(Ewk_Context* ewkContext,
 
     ssMsg << "_" << scale << " ";
 
-    if(encodedBundle)
-    {
+    if (encodedBundle) {
         ssMsg << "_" << encodedBundle << " ";
-    }
-    else
-    {
+    } else {
         ssMsg << "null" << " ";
     }
 
-    if(theme)
-    {
+    if (theme) {
         ssMsg << "_" << theme << " ";
-    }
-    else
-    {
+    } else {
         ssMsg << "null" << " ";
     }
 
@@ -86,37 +79,28 @@ void shutdown(Ewk_Context* ewkContext)
 }
 
 void setCustomProperties(
-        Ewk_Context* ewkContext,
-        double* scale,
-        const char* encodedBundle,
-        const char* theme )
+    Ewk_Context* ewkContext,
+    double* scale,
+    const char* encodedBundle,
+    const char* theme)
 {
     std::stringstream ssMsg;
 
-    if(scale)
-    {
+    if (scale) {
         ssMsg << "_" << *scale << " ";
-    }
-    else
-    {
+    } else {
         ssMsg << "null" << " ";
     }
 
-    if(encodedBundle)
-    {
+    if (encodedBundle) {
         ssMsg << "_" << encodedBundle << " ";
-    }
-    else
-    {
+    } else {
         ssMsg << "null" << " ";
     }
 
-    if(theme)
-    {
+    if (theme) {
         ssMsg << "_" << theme;
-    }
-    else
-    {
+    } else {
         ssMsg << "null";
     }
 
@@ -129,9 +113,9 @@ void setCustomProperties(
 }
 
 void dispatchJavaScriptEvent(
-        Ewk_Context* ewkContext,
-        WrtPlugins::W3C::CustomEventType eventType,
-        void *data)
+    Ewk_Context* ewkContext,
+    WrtPlugins::W3C::CustomEventType eventType,
+    void *data)
 {
     using namespace WrtPlugins::W3C;
     std::stringstream str;
@@ -155,16 +139,4 @@ void dispatchJavaScriptEvent(
     ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
 }
 
-void suspend(Ewk_Context* ewkContext)
-{
-    const char* name = BundleMessages::SUSPEND;
-    ewk_context_message_post_to_injected_bundle(ewkContext, name, name);
-}
-
-void resume(Ewk_Context* ewkContext)
-{
-    const char* name = BundleMessages::RESUME;
-    ewk_context_message_post_to_injected_bundle(ewkContext, name, name);
-}
-
-}//namespace PluginModuleSupport
+} //namespace PluginModuleSupport
index 4889645..2ff3a26 100644 (file)
@@ -36,19 +36,15 @@ void start(Ewk_Context* ewkContext,
            const char *theme,
            bool encrypted);
 void shutdown(Ewk_Context* ewkContext);
-
-void suspend(Ewk_Context* ewkContext);
-void resume(Ewk_Context* ewkContext);
-
 void setCustomProperties(
-        Ewk_Context* ewkContext,
-        double* scale = NULL,
-        const char* encodedBundle = NULL,
-        const char* theme = NULL);
+    Ewk_Context* ewkContext,
+    double* scale = NULL,
+    const char* encodedBundle = NULL,
+    const char* theme = NULL);
 void dispatchJavaScriptEvent(
-        Ewk_Context* ewkContext,
-        WrtPlugins::W3C::CustomEventType eventType,
-        void* data);
+    Ewk_Context* ewkContext,
+    WrtPlugins::W3C::CustomEventType eventType,
+    void* data);
 } // namespace PluginModuleSupport
 
 #endif /* WRT_SRC_VIEW_WEBKIT2_PLUGIN_MODULE_SUPPORT_H_ */
index fa3f957..c374f9e 100644 (file)
@@ -53,6 +53,8 @@
 #include <dpl/utils/mime_type_utils.h>
 #include <dpl/localization/LanguageTagsProvider.h>
 #include <dpl/event/main_event_dispatcher.h>
+#include <FBaseByteBuffer.h>
+#include <security/FSecCrypto_TrustZoneService.h>
 
 #include <wrt_plugin_module.h>
 #include <profiling_util.h>
@@ -73,6 +75,7 @@
 
 namespace {
 const char * const uriChangedMessageName = "uri_changed_msg";
+const char * const uriBlockedMessageName = "uri_blocked_msg";
 const char * const URICHANGE_PLUGIN_STOP_ONLY = "plugin_stop_only";
 const char * const URICHANGE_PLUGIN_RESTART = "plugin_restart";
 const char * const URICHANGE_PLUGIN_NO_CHANGE = "plugin_no_change";
@@ -87,6 +90,8 @@ const char * const HTML_MIME = "text/html";
 const char * const PHP_MIME = "application/x-php";
 const char * const VIEWMODE_TYPE_FULLSCREEN = "fullscreen";
 const char * const VIEWMODE_TYPE_MAXIMIZED = "maximized";
+const std::size_t FILE_BUF_MAX_SIZE = 1024; // bytes
+const std::size_t PLAIN_CHUNK_SIZE = 1008; // bytes
 }
 
 Bundle::Bundle(WKBundleRef bundle) :
@@ -94,9 +99,10 @@ Bundle::Bundle(WKBundleRef bundle) :
     m_scale(0),
     m_encodedBundle(""),
     m_theme(""),
+    m_willRemoveContext(NULL),
     m_encrypted(false),
-    m_resDec(NULL),
-    m_widgetType(WrtDB::APP_TYPE_UNKNOWN)
+    m_widgetType(WrtDB::APP_TYPE_UNKNOWN),
+    m_initialized(false)
 {
     LOG_PROFILE_START("Bundle attachToThread");
     WrtDB::WrtDatabase::attachToThreadRO();
@@ -108,8 +114,7 @@ Bundle::~Bundle()
 {
     WrtDB::WrtDatabase::detachFromThread();
 
-    if (!m_pagesList.empty())
-    {
+    if (!m_pagesList.empty()) {
         LogError("There are not closed pages!");
     }
 
@@ -118,9 +123,9 @@ Bundle::~Bundle()
 }
 
 void Bundle::didCreatePageCallback(
-        WKBundleRef /*bundle*/,
-        WKBundlePageRef page,
-        const void* clientInfo)
+    WKBundleRef /*bundle*/,
+    WKBundlePageRef page,
+    const void* clientInfo)
 {
     LOG_PROFILE_START("didCreatePageCallback");
     LogDebug("didCreatePageCallback called");
@@ -130,10 +135,10 @@ void Bundle::didCreatePageCallback(
 }
 
 void Bundle::didReceiveMessageCallback(
-        WKBundleRef /*bundle*/,
-        WKStringRef messageName,
-        WKTypeRef messageBody,
-        const void *clientInfo)
+    WKBundleRef /*bundle*/,
+    WKStringRef messageName,
+    WKTypeRef messageBody,
+    const void *clientInfo)
 {
     LogDebug("didReceiveMessageCallback called");
     Bundle* bundle = static_cast<Bundle*>(const_cast<void*>(clientInfo));
@@ -141,9 +146,9 @@ void Bundle::didReceiveMessageCallback(
 }
 
 void Bundle::willDestroyPageCallback(
-        WKBundleRef /*bundle*/,
-        WKBundlePageRef page,
-        const void* clientInfo)
+    WKBundleRef /*bundle*/,
+    WKBundlePageRef page,
+    const void* clientInfo)
 {
     LogDebug("willDestroyPageCallback called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
@@ -158,7 +163,7 @@ void Bundle::didCreatePage(WKBundlePageRef page)
     m_pageGlobalContext[page] = context;
     LogDebug("created Page : " << page << " created JSContext : " << context);
 
-    WKBundlePageResourceLoadClient resourceLoadClient =  {
+    WKBundlePageResourceLoadClient resourceLoadClient = {
         kWKBundlePageResourceLoadClientCurrentVersion,  /* version */
         this, /* clientinfo */
         0, /* didInitiateLoadForResource */
@@ -172,19 +177,53 @@ void Bundle::didCreatePage(WKBundlePageRef page)
     };
     WKBundlePageSetResourceLoadClient(page, &resourceLoadClient);
 
-    connectLoaderClientCallbacksToPage(page);
+    WKBundlePageLoaderClient loaderClient = {
+        kWKBundlePageLoaderClientCurrentVersion,
+        this, /* clientinfo */
+        didStartProvisionalLoadForFrameCallback, /* didStartProvisionalLoadForFrame */
+        0, /* didReceiveServerRedirectForProvisionalLoadForFrame */
+        0, /* didFailProvisionalLoadWithErrorForFrame */
+        didCommitLoadForFrameCallback, /* didCommitLoadForFrame */
+        0, /* didFinishDocumentLoadForFrame */
+        0, /* didFinishLoadForFrame */
+        0, /* didFailLoadWithErrorForFrame */
+        0, /* didSameDocumentNavigationForFrame */
+        0, /* didReceiveTitleForFrame */
+        0, /* didFirstLayoutForFrame */
+        0, /* didFirstVisuallyNonEmptyLayoutForFrame */
+        didRemoveFrameFromHierarchyCallback, /* didRemoveFrameFromHierarchy */
+        0, /* didDisplayInsecureContentForFrame */
+        0, /* didRunInsecureContentForFrame */
+        0, /* didClearWindowObjectForFrame */
+        0, /* didCancelClientRedirectForFrame */
+        0, /* willPerformClientRedirectForFrame */
+        0, /* didHandleOnloadEventsForFrame */
+        0, /* didLayoutForFrame */
+        0, /* didNewFirstVisuallyNonEmptyLayout */
+        0, /* didDetectXSSForFrame */
+        0, /* shouldGoToBackForwardListItem */
+        0, /* globalObjectIsAvailableForFrame */
+        0, /* willDisconnectDOMWindowExtensionFromGlobalObject */
+        0, /* didReconnectDOMWindowExtensionToGlobalObject */
+        0, /* willDestroyGlobalObjectForDOMWindowExtension */
+        0, /* didFinishProgress */
+        0, /* shouldForceUniversalAccessFromLocalURL */
+        0, /* didReceiveIntentForFrame */
+        0, /* registerIntentServiceForFrame */
+    };
+    WKBundlePageSetPageLoaderClient(page, &loaderClient);
+
 
     WKBundlePagePolicyClient policyClient = {
         kWKBundlePagePolicyClientCurrentVersion,        /* version */
         this,                                           /* clientInfo */
-        pageDecidePolicyForNavigationActionCallback,    /* decidePolicyForNavigationAction */
-        0,                                              /* decidePolicyForNewWindowAction */
-        pageDecidePolicyForResponseCallback,            /* decidePolicyForResponse */
-        0,                                              /* unableToImplementPolicy */
+        pageDecidePolicyForNavigationActionCallback,    /**/
+        0,                                 /* decidePolicyForNewWindowAction */
+        pageDecidePolicyForResponseCallback,    /* decidePolicyForResponse */
+        0,                                      /* unableToImplementPolicy */
     };
     WKBundlePageSetPolicyClient(page, &policyClient);
-
-};
+}
 
 void Bundle::willDestroyPage(WKBundlePageRef page)
 {
@@ -193,30 +232,30 @@ void Bundle::willDestroyPage(WKBundlePageRef page)
     auto context = m_pageGlobalContext[page];
     m_pagesList.remove(page);
     m_pageGlobalContext.erase(page);
-    m_pageContext.erase(page);
+    m_pageContext[page].erase(context);
 
+    PluginModule::unloadFrame(context);
     PluginModule::stop(context);
 }
 
-void Bundle::fixWKMessageArgs(std::string & argScale, std::string & argEncodedBundle, std::string & argTheme)
+void Bundle::fixWKMessageArgs(std::string & argScale,
+                              std::string & argEncodedBundle,
+                              std::string & argTheme)
 {
-    if (argScale != "null" && argScale[0] == '_')
-    {
+    if (argScale != "null" && argScale[0] == '_') {
         argScale.erase(0, 1);
 
         std::stringstream ssScale(argScale);
         ssScale >> m_scale;
     }
 
-    if (argEncodedBundle != "null" && argEncodedBundle[0] == '_')
-    {
+    if (argEncodedBundle != "null" && argEncodedBundle[0] == '_') {
         argEncodedBundle.erase(0, 1);
 
         m_encodedBundle = argEncodedBundle;
     }
 
-    if (argTheme != "null" && argTheme[0] == '_')
-    {
+    if (argTheme != "null" && argTheme[0] == '_') {
         argTheme.erase(0, 1);
 
         m_theme = argTheme;
@@ -256,32 +295,17 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
 
         // ** Language tags setting completed **
         fixWKMessageArgs(argScale, argEncodedBundle, argTheme);
-    }
-    else if (WKStringIsEqualToUTF8CString(messageName,
-                                          BundleMessages::SHUTDOWN))
+    } else if (WKStringIsEqualToUTF8CString(messageName,
+                                            BundleMessages::SHUTDOWN))
     {
         LogDebug("shutdown plugins");
 
-        if (m_pagesList.empty())
-        {
+        if (m_pagesList.empty()) {
             PluginModule::shutdown();
+        } else {
+            LogInfo(
+                "PluginModule shutdown ignored, there are still alive pages!");
         }
-        else
-        {
-            LogInfo("PluginModule shutdown ignored, there are still alive pages!");
-        }
-    }
-    else if (WKStringIsEqualToUTF8CString(messageName,
-                                          BundleMessages::SUSPEND))
-    {
-        LogDebug("suspend plugins");
-        requestSuspend();
-    }
-    else if (WKStringIsEqualToUTF8CString(messageName,
-                                          BundleMessages::RESUME))
-    {
-        LogDebug("resume plugins");
-        requestResume();
     }
     else if (WKStringIsEqualToUTF8CString(messageName,
                                           BundleMessages::SET_CUSTOM_PROPERTIES))
@@ -303,17 +327,15 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
 
         //apply for each context
         PageGlobalContext::iterator it = m_pageGlobalContext.begin();
-        for (; it != m_pageGlobalContext.end(); ++it)
-        {
+        for (; it != m_pageGlobalContext.end(); ++it) {
             PluginModule::setCustomProperties(it->second,
                                               m_scale,
                                               m_encodedBundle.c_str(),
                                               m_theme.c_str());
         }
-    }
-    else if (WKStringIsEqualToUTF8CString(
-                 messageName,
-                 BundleMessages::DISPATCH_JAVASCRIPT_EVENT))
+    } else if (WKStringIsEqualToUTF8CString(
+                   messageName,
+                   BundleMessages::DISPATCH_JAVASCRIPT_EVENT))
     {
         LogDebug("dispatch javascript event to created frames");
         // set information from ui process
@@ -334,64 +356,73 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
 
         //apply for each context
         PageGlobalContext::iterator it = m_pageGlobalContext.begin();
-        for (; it != m_pageGlobalContext.end(); ++it)
-        {
+        for (; it != m_pageGlobalContext.end(); ++it) {
             PluginModule::dispatchJavaScriptEvent(
-                    it->second,
-                    static_cast<WrtPlugins::W3C::CustomEventType>(eventType),
-                    args);
+                it->second,
+                static_cast<WrtPlugins::W3C::CustomEventType>(eventType),
+                args);
         }
 
         if (args) {
             delete static_cast<SoftKeyboardChangeArgs *>(args);
         }
-    }
-    else if (WKStringIsEqualToUTF8CString(
-             messageName,
-             BundleMessages::INIT))
+    } else if (WKStringIsEqualToUTF8CString(
+                   messageName,
+                   BundleMessages::INIT))
     {
         LogDebug("initializing plugins");
-        auto msgString = toString(static_cast<WKStringRef>(messageBody));
 
-        m_widgetTizenId = DPL::FromASCIIString(msgString);
-
-        WrtDB::WidgetDAOReadOnly dao(m_widgetTizenId);
-        /* This type of message is received when widget is restarting
-         * (proably in other situation too). Widget restart can be
-         * called after system language change so language tags have to
-         * be recreated here.
-         * Do NOT MOVE LanguageTags reset before m_widgetHandle initialization
-         */
-        // reset language tags (create new tags based on system locales)
-        LanguageTagsProviderSingleton::Instance().resetLanguageTags();
-        DPL::OptionalString defaultLocale = dao.getDefaultlocale();
-        if(!defaultLocale.IsNull())
+        if (!m_initialized)
         {
-            LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defaultLocale);
-        }
-        LanguageTags tags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
-        LogDebug("Current widget locales (language tags):");
-        FOREACH(it, tags) {
-            LogDebug("Locale: " << *it);
-        }
+            auto msgString = toString(static_cast<WKStringRef>(messageBody));
+
+            m_widgetTizenId = DPL::FromASCIIString(msgString);
+
+            WrtDB::WidgetDAOReadOnly dao(m_widgetTizenId);
+            /* This type of message is received when widget is restarting
+             * (proably in other situation too). Widget restart can be
+             * called after system language change so language tags have to
+             * be recreated here.
+             * Do NOT MOVE LanguageTags reset before m_widgetHandle initialization
+             */
+            // reset language tags (create new tags based on system locales)
+            LanguageTagsProviderSingleton::Instance().resetLanguageTags();
+            DPL::OptionalString defaultLocale = dao.getDefaultlocale();
+            if (!defaultLocale.IsNull()) {
+                LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
+                    *defaultLocale);
+            }
+            LanguageTags tags =
+                LanguageTagsProviderSingleton::Instance().getLanguageTags();
+            LogDebug("Current widget locales (language tags):");
+            FOREACH(it, tags) {
+                LogDebug("Locale: " << *it);
+            }
+
+            m_widgetType = dao.getWidgetType();
+            LogDebug("m_widgetType : " << m_widgetType.getApptypeToString() <<
+                     "(m_widgetTizenId:" << m_widgetTizenId << ")");
 
-        m_widgetType = dao.getWidgetType();
-        LogDebug("m_widgetType : " << m_widgetType.getApptypeToString() <<
-                 "(m_widgetTizenId:" << m_widgetTizenId << ")");
+            LogDebug("Preload PluginLogicSingleton");
+            PluginModule::init(WrtDB::WidgetDAOReadOnly::getHandle(m_widgetTizenId));
+            LogDebug("Preload PluginLogicSingleton_end");
 
-        LogDebug("Preload PluginLogicSingleton");
-        PluginModule::init(WrtDB::WidgetDAOReadOnly::getHandle(m_widgetTizenId));
-        LogDebug("Preload PluginLogicSingleton_end");
+            m_initialized = true;
+        }
+        else
+        {
+            LogDebug("already initalized");
+        }
     }
 }
 
 WKURLRequestRef Bundle::willSendRequestForFrameCallback(
-        WKBundlePageRef /*page*/,
-        WKBundleFrameRef /*frame*/,
-        uint64_t /*resourceIdentifier*/,
-        WKURLRequestRef request,
-        WKURLResponseRef /*response*/,
-        const void *clientInfo)
+    WKBundlePageRef /*page*/,
+    WKBundleFrameRef /*frame*/,
+    uint64_t /*resourceIdentifier*/,
+    WKURLRequestRef request,
+    WKURLResponseRef /*response*/,
+    const void *clientInfo)
 {
     LogDebug("willSendRequestForFrameCallback called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
@@ -399,10 +430,10 @@ WKURLRequestRef Bundle::willSendRequestForFrameCallback(
 }
 
 void Bundle::didStartProvisionalLoadForFrameCallback(
-        WKBundlePageRef page,
-        WKBundleFrameRef frame,
-        WKTypeRef* /*userData*/,
-        const void *clientInfo)
+    WKBundlePageRef page,
+    WKBundleFrameRef frame,
+    WKTypeRef* /*userData*/,
+    const void *clientInfo)
 {
     LogDebug("didStartProvisionalLoadForFrameCallback called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
@@ -439,25 +470,20 @@ void Bundle::didStartProvisionalLoadForFrameCallback(
     }
 
     This->m_pageContext[page].erase(i);
-
-    PluginModule::unloadFrame(context);
+    This->m_willRemoveContext = context;
 }
 
 void Bundle::didRemoveFrameFromHierarchyCallback(
-        WKBundlePageRef page,
-        WKBundleFrameRef frame,
-        WKTypeRef* /*userData*/,
-        const void *clientInfo)
+    WKBundlePageRef page,
+    WKBundleFrameRef frame,
+    WKTypeRef* /*userData*/,
+    const void *clientInfo)
 {
-    LogDebug("didFinishLoadForResourceCallback called");
+    LogDebug("didRemoveFrameFromHierarchyCallback called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
 
-    if (This->m_pageGlobalContext.count(page) == 0)
-    {
-        return;
-    }
-    if (This->m_pageContext.count(page) == 0)
-    {
+    if (This->m_pageContext.count(page) == 0) {
+        LogDebug("his->m_pageContext.count(page) == 0");
         return;
     }
 
@@ -465,8 +491,7 @@ void Bundle::didRemoveFrameFromHierarchyCallback(
 
     ContextSet::iterator i = This->m_pageContext[page].find(context);
 
-    if (i == This->m_pageContext[page].end())
-    {
+    if (i == This->m_pageContext[page].end()) {
         LogWarning("Tried to unload frame which has never been loaded");
         return;
     }
@@ -477,45 +502,19 @@ void Bundle::didRemoveFrameFromHierarchyCallback(
 }
 
 void Bundle::didFinishLoadForResourceCallback(
-        WKBundlePageRef /*page*/,
-        WKBundleFrameRef frame,
-        uint64_t /*resourceIdentifier*/,
-        const void* clientInfo)
+    WKBundlePageRef /*page*/,
+    WKBundleFrameRef /*frame*/,
+    uint64_t /*resourceIdentifier*/,
+    const void* /*clientInfo*/)
 {
     LogDebug("didFinishLoadForResourceCallback called");
-    Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
-
-    WKURLRef url = WKBundleFrameCopyURL(frame);
-    WKTypeRef retVal = NULL;
-
-    // If url is NULL, this url has been already blocked by willsend
-    // So current page should be moved to previous page
-    if (url == NULL)
-    {
-        if (WKBundleFrameIsMainFrame(frame))
-        {
-            LogInfo("url is NULL. Go back to previous view");
-            WKStringRef blockedURL =
-                WKStringCreateWithUTF8CString(URICHANGE_BLOCKED_URL);
-            WKBundlePostSynchronousMessage(This->m_bundle,
-                                        This->m_uriChangedMessage,
-                                        blockedURL,
-                                        &retVal);
-        }
-        else
-        {
-            LogInfo("Blocked uri in IFrame.");
-        }
-        return;
-    }
-    WKRelease(url);
 }
 
 void Bundle::didCommitLoadForFrameCallback(
-        WKBundlePageRef page,
-        WKBundleFrameRef frame,
-        WKTypeRef* /*userData*/,
-        const void *clientInfo)
+    WKBundlePageRef page,
+    WKBundleFrameRef frame,
+    WKTypeRef* /*userData*/,
+    const void *clientInfo)
 {
     LogInfo("didCommitLoadForFrameCallback called");
     LOG_PROFILE_START("didCommitLoadForFrameCallback");
@@ -529,19 +528,23 @@ void Bundle::didCommitLoadForFrameCallback(
         return;
     }
 
+    if (This->m_willRemoveContext) {
+        PluginModule::unloadFrame(This->m_willRemoveContext);
+        This->m_willRemoveContext = NULL;
+    }
+
     JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame);
 
     This->m_pageContext[page].insert(context);
 
-    if (!WKBundleFrameIsMainFrame(frame))
-    {
+    if (!WKBundleFrameIsMainFrame(frame)) {
         LogInfo("frame isn't main frame");
         PluginModule::start(
-                    WrtDB::WidgetDAOReadOnly::getHandle(This->m_widgetTizenId),
-                    context,
-                    This->m_scale,
-                    This->m_encodedBundle.c_str(),
-                    This->m_theme.c_str());
+            WrtDB::WidgetDAOReadOnly::getHandle(This->m_widgetTizenId),
+            context,
+            This->m_scale,
+            This->m_encodedBundle.c_str(),
+            This->m_theme.c_str());
         PluginModule::loadFrame(context);
         return;
     }
@@ -549,8 +552,7 @@ void Bundle::didCommitLoadForFrameCallback(
     std::string scheme = getScheme(toString(url));
     std::string result = URICHANGE_PLUGIN_RESTART;
 
-    if (scheme == SCHEME_HTTP || scheme == SCHEME_HTTPS)
-    {
+    if (scheme == SCHEME_HTTP || scheme == SCHEME_HTTPS) {
         WKStringRef urlStr = WKURLCopyString(url);
         WKBundlePostSynchronousMessage(This->m_bundle,
                                        This->m_uriChangedMessage,
@@ -563,21 +565,18 @@ void Bundle::didCommitLoadForFrameCallback(
     }
     LogInfo("result from UI process : " << result);
 
-    if (result == URICHANGE_PLUGIN_STOP_ONLY)
-    {
+    if (result == URICHANGE_PLUGIN_STOP_ONLY) {
         PluginModule::stop(context);
-    }
-    else if (result == URICHANGE_PLUGIN_RESTART)
-    {
+    } else if (result == URICHANGE_PLUGIN_RESTART) {
         PluginModule::stop(context);
         This->m_pageGlobalContext[page] = context;
         LOG_PROFILE_START("PluginModule start");
         PluginModule::start(
-                WrtDB::WidgetDAOReadOnly::getHandle(This->m_widgetTizenId),
-                context,
-                This->m_scale,
-                This->m_encodedBundle.c_str(),
-                This->m_theme.c_str() );
+            WrtDB::WidgetDAOReadOnly::getHandle(This->m_widgetTizenId),
+            context,
+            This->m_scale,
+            This->m_encodedBundle.c_str(),
+            This->m_theme.c_str() );
         LOG_PROFILE_STOP("PluginModule start");
 
         PluginModule::loadFrame(context);
@@ -586,12 +585,12 @@ void Bundle::didCommitLoadForFrameCallback(
 }
 
 WKBundlePagePolicyAction Bundle::pageDecidePolicyForNavigationActionCallback(
-        WKBundlePageRef             page,
-        WKBundleFrameRef            frame,
-        WKBundleNavigationActionRef navigationAction,
-        WKURLRequestRef             request,
-        WKTypeRef*                  userData,
-        const void*                 clientInfo)
+    WKBundlePageRef page,
+    WKBundleFrameRef frame,
+    WKBundleNavigationActionRef navigationAction,
+    WKURLRequestRef request,
+    WKTypeRef*                  userData,
+    const void*                 clientInfo)
 {
     LogDebug("pageDecidePolicyForNavigationActionCallback called");
 
@@ -605,12 +604,12 @@ WKBundlePagePolicyAction Bundle::pageDecidePolicyForNavigationActionCallback(
 }
 
 WKBundlePagePolicyAction Bundle::pageDecidePolicyForResponseCallback(
-        WKBundlePageRef     /* page */,
-        WKBundleFrameRef    /* frame */,
-        WKURLResponseRef    response,
-        WKURLRequestRef     /* request */,
-        WKTypeRef*          /* userData */,
-        const void*         /* clientInfo */)
+    WKBundlePageRef /* page */,
+    WKBundleFrameRef /* frame */,
+    WKURLResponseRef response,
+    WKURLRequestRef /* request */,
+    WKTypeRef*          /* userData */,
+    const void*         /* clientInfo */)
 {
     LogDebug("pageDecidePolicyForResponseCallback called");
 
@@ -621,13 +620,11 @@ WKBundlePagePolicyAction Bundle::pageDecidePolicyForResponseCallback(
     LogDebug("contentTypeRef : " << contentType);
     WKRelease(contentTypeRef);
 
-    if (contentType == HTML_MIME)
-    {
+    if (contentType == HTML_MIME) {
         LogDebug("Accepting HTML_MIME type");
         return WKBundlePagePolicyActionUse;
     }
-    if (contentType == PHP_MIME)
-    {
+    if (contentType == PHP_MIME) {
         LogDebug("Accepting php type");
         return WKBundlePagePolicyActionUse;
     }
@@ -644,82 +641,83 @@ WKURLRequestRef Bundle::willSendRequestForFrame(WKURLRequestRef request)
     bool is_xhr = true; // Webkit should inform if it's XHR
     DPL::String dplurl = DPL::FromUTF8String(toString(urlStr));
     WKRelease(urlStr);
-    DPL::Optional<DPL::String> newurl = BundleURIHandling::processURI(dplurl,
-            is_xhr, m_widgetTizenId, m_bundle);
 
-    if (newurl.IsNull()) {
-        LogDebug("URI is blocked");
-        WKRelease(url);
+    DPL::Optional<DPL::String> localizedUrl =
+        BundleURIHandling::localizeURI(dplurl, m_widgetTizenId);
+    bool ret = BundleURIHandling::processURI(
+            *localizedUrl,
+            is_xhr,
+            m_widgetTizenId,
+            m_bundle);
+
+    if (!ret) {
+        LogDebug("Not permitted resource: " << *localizedUrl);
         return NULL;
+    }
+
+    LogDebug("URI processing result: " << *localizedUrl);
+    std::string tmpUrlStr = DPL::ToUTF8String(*localizedUrl);
+    WKURLRef tmpUrl = WKURLCreateWithUTF8CString(tmpUrlStr.c_str());
+    std::string scheme = toString(WKURLCopyScheme(url));
+    WKRelease(url);
+    // Return value must contain details information of input
+    // WKURLRequestRef. Current webkit2 doesn't support api that
+    // copy WKURLRequestRef or change url only. Before webkit2
+    // support api, callback return original WKURLRequestRef in the
+    // case of external scheme
+
+    // external scheme also need to send message to UI process for
+    // checking roaming and security
+    if (scheme == SCHEME_HTTP || scheme == SCHEME_HTTPS) {
+        LogDebug("external scheme return original WKURLRequestRef");
+        WKRelease(tmpUrl);
+        WKRetain(request);
+        return request;
     } else {
-        LogDebug("URI processing result: " << *newurl );
-        std::string tmpUrlStr = DPL::ToUTF8String(*newurl);
-        if (tmpUrlStr.empty()) {
-            LogDebug("uri is blocked");
-            WKRelease(url);
-            return NULL;
-        }
+        std::string checkUrl = toString(tmpUrl);
 
-        WKURLRef tmpUrl = WKURLCreateWithUTF8CString(tmpUrlStr.c_str());
-        std::string scheme = toString(WKURLCopyScheme(url));
-        WKRelease(url);
-        // Return value must contain details information of input
-        // WKURLRequestRef. Current webkit2 doesn't support api that
-        // copy WKURLRequestRef or change url only. Before webkit2
-        // support api, callback return original WKURLRequestRef in the
-        // case of external scheme
-
-        // external scheme also need to send message to UI process for
-        // checking roaming and security
-        if (scheme == SCHEME_HTTP || scheme == SCHEME_HTTPS) {
-            LogDebug("external scheme return original WKURLRequestRef");
-            WKRelease(tmpUrl);
-            WKRetain(request);
-            return request;
-        } else {
-            std::string checkUrl = toString(tmpUrl);
+        if (m_encrypted) {
             int getFileSize;
-
-            if(m_encrypted) {
-                if(isEncryptedResource(checkUrl, getFileSize)) {
-                    std::string decryptString = DecryptResource(checkUrl,
-                            getFileSize);
-                    if (!decryptString.empty()) {
-                        std::string destString = DATA_STRING;
-
-                        std::string mimeString =
-                            DPL::ToUTF8String(MimeTypeUtils::identifyFileMimeType(
-                                        DPL::FromUTF8String(checkUrl)));
-
-                        destString += mimeString;
-                        destString += BASE64_STRING;
-
-                        decryptString.insert(0, destString);
-
-                        WKURLRef destUrl =
-                            WKURLCreateWithUTF8CString(decryptString.c_str());
-
-                        WKURLRequestRef req = WKURLRequestCreateWithWKURL(destUrl);
-                        WKRelease(destUrl);
-                        LogDebug("return value " << decryptString << "]]");
-                        return req;
-                    }
+            if (isEncryptedResource(checkUrl, getFileSize)) {
+                std::string decryptString = DecryptResource(checkUrl,
+                                                            getFileSize);
+                if (!decryptString.empty()) {
+                    std::string destString = DATA_STRING;
+
+                    std::string mimeString =
+                        DPL::ToUTF8String(
+                            MimeTypeUtils::identifyFileMimeType(
+                                DPL::FromUTF8String(checkUrl)));
+
+                    destString += mimeString;
+                    destString += BASE64_STRING;
+
+                    decryptString.insert(0, destString);
+
+                    WKURLRef destUrl =
+                        WKURLCreateWithUTF8CString(decryptString.c_str());
+
+                    WKURLRequestRef req = WKURLRequestCreateWithWKURL(
+                            destUrl);
+                    WKRelease(destUrl);
+                    LogDebug("return value " << decryptString << "]]");
+                    return req;
                 }
             }
-            WKURLRequestRef req = WKURLRequestCreateWithWKURL(tmpUrl);
-            WKRelease(tmpUrl);
-            LogDebug("return value " << toString(req).c_str());
-            return req;
         }
+        WKURLRequestRef req = WKURLRequestCreateWithWKURL(tmpUrl);
+        WKRelease(tmpUrl);
+        LogDebug("return value " << toString(req).c_str());
+        return req;
     }
 }
 
 WKBundlePagePolicyAction Bundle::pageDecidePolicyForNavigationAction(
-       WKBundlePageRef             /* page */,
-       WKBundleFrameRef            frame,
-       WKBundleNavigationActionRef /* navigationAction */,
-       WKURLRequestRef             request,
-       WKTypeRef*                  /* userData */)
+    WKBundlePageRef /* page */,
+    WKBundleFrameRef frame,
+    WKBundleNavigationActionRef /* navigationAction */,
+    WKURLRequestRef request,
+    WKTypeRef*                  /* userData */)
 {
     using namespace ViewModule;
     using namespace ViewModule::SchemeActionMap;
@@ -731,17 +729,35 @@ WKBundlePagePolicyAction Bundle::pageDecidePolicyForNavigationAction(
     LogInfo("Uri being checked: " << request_uri);
 
     // exception uri
-    if( request_uri == BLANK_PAGE_URL )
-    {
+    if (request_uri == BLANK_PAGE_URL) {
         return WKBundlePagePolicyActionUse;
     }
 
+    // WARP & ACE Check
+    DPL::String dplUrl = DPL::FromUTF8String(request_uri);
+    DPL::Optional<DPL::String> localizedUrl =
+        BundleURIHandling::localizeURI(dplUrl, m_widgetTizenId);
+    bool ret = BundleURIHandling::processURI(
+            *localizedUrl, true, m_widgetTizenId, m_bundle);
+    if (!ret) {
+        std::string blockedUrl = DPL::ToUTF8String(*localizedUrl);
+        LogDebug("URI is blocked: " << blockedUrl);
+
+        // Send information about blocked URI to UIProcess
+        WKStringRef urlStr = WKStringCreateWithUTF8CString(blockedUrl.c_str());
+        WKTypeRef retVal = NULL;
+        WKStringRef blockMessage = WKStringCreateWithUTF8CString(uriBlockedMessageName);
+        WKBundlePostSynchronousMessage(m_bundle, blockMessage, urlStr, &retVal);
+        WKRelease(urlStr);
+        WKRelease(retVal);
+        WKRelease(blockMessage);
+    }
+
     // get scheme string
     std::string request_scheme = getScheme(request_uri);
 
     // is tizen schem?
-    if ( request_scheme == TIZEN_SCHEME )
-    {
+    if (request_scheme == TIZEN_SCHEME) {
         return WKBundlePagePolicyActionPassThrough;
     }
 
@@ -764,29 +780,22 @@ WKBundlePagePolicyAction Bundle::pageDecidePolicyForNavigationAction(
 
     UriAction action;
 
-    if (m_widgetType == WrtDB::APP_TYPE_WAC20)
-    {
+    if (m_widgetType == WrtDB::APP_TYPE_WAC20) {
         action = g_wacActionMap[type][ctx];
-    }
-    else if (m_widgetType == WrtDB::APP_TYPE_TIZENWEBAPP)
-    {
+    } else if (m_widgetType == WrtDB::APP_TYPE_TIZENWEBAPP) {
         action = g_tizenActionMap[type][ctx];
-    }
-    else
-    {
+    } else {
         LogError("Unsupported application type: " << type);
         return WKBundlePagePolicyActionPassThrough;
     }
 
     LogDebug("Uri action: " << action);
 
-    if (action == URI_ACTION_WRT)
-    {
-        return WKBundlePagePolicyActionUse;
+    if (action != URI_ACTION_WRT) {
+        return WKBundlePagePolicyActionPassThrough;
     }
 
-    return WKBundlePagePolicyActionPassThrough;
-
+    return WKBundlePagePolicyActionUse;
 }
 
 std::string Bundle::toString(WKStringRef str)
@@ -831,8 +840,7 @@ std::string Bundle::getScheme(std::string uri)
     std::size_t found = uri.find(':');
     std::string str;
 
-    if (found != std::string::npos)
-    {
+    if (found != std::string::npos) {
         str = uri.substr(0, found);
     }
 
@@ -844,8 +852,8 @@ bool Bundle::isEncryptedResource(std::string Url, int &size)
     std::string filePath;
 
     size_t pos = Url.find_first_not_of(SCHEME_FILE);
-    if ( std::string::npos != pos) {
-        filePath = Url.substr(pos-1);
+    if (std::string::npos != pos) {
+        filePath = Url.substr(pos - 1);
     }
 
     if (m_encryptedFiles.empty()) {
@@ -858,8 +866,9 @@ bool Bundle::isEncryptedResource(std::string Url, int &size)
     info.fileName = DPL::FromUTF8String(filePath);
 
     if ((0 == strncmp(Url.c_str(), SCHEME_FILE, strlen(SCHEME_FILE))) &&
-            (m_encryptedFiles.end() != (it =
-             m_encryptedFiles.find(info)))) {
+        (m_encryptedFiles.end() != (it =
+                                        m_encryptedFiles.find(info))))
+    {
         LogDebug(" info file name : " << it->fileName);
         LogDebug(" info file size : " << it->fileSize);
         size = it->fileSize;
@@ -873,44 +882,48 @@ std::string Bundle::DecryptResource(std::string resource, int size)
     std::string filePath;
 
     size_t pos = resource.find_first_not_of(SCHEME_FILE);
-    if ( std::string::npos != pos) {
-        filePath = resource.substr(pos-1);
+    if (std::string::npos != pos) {
+        filePath = resource.substr(pos - 1);
     }
 
     struct stat buf;
     if (0 == stat(filePath.c_str(), &buf)) {
-        if (NULL == m_resDec) {
-            using namespace WrtDB;
-            m_resDec = new
-                WRTDecryptor::ResourceDecryptor(DPL::ToUTF8String(m_widgetTizenId));
-            WrtDB::WidgetDAOReadOnly(m_widgetTizenId).
-                getEncryptedFileList(m_encryptedFiles);
-        }
-        size_t bufSize = buf.st_size;
-        unsigned char contents[bufSize];
-        memset(contents, 0, bufSize);
+        const std::size_t fileSize = buf.st_size;
+        const std::size_t readBufSize = (fileSize > FILE_BUF_MAX_SIZE
+                ? FILE_BUF_MAX_SIZE : fileSize);
+
+        std::unique_ptr<unsigned char[]> inChunk(new unsigned char[readBufSize]);
 
         FILE* fp = fopen(filePath.c_str(), "rb");
-        if ( NULL == fp) {
+        if (NULL == fp) {
             LogDebug("Couldnot open file : " << filePath);
             return std::string();
         }
 
-        size_t ret = fread(contents, sizeof(unsigned char), buf.st_size, fp);
-        if (ret <  static_cast<size_t>(buf.st_size) ){
-            LogDebug("Couldnot read file : " << filePath);
-            fclose(fp);
-            return std::string();
-        }
+        std::unique_ptr<unsigned char[]> DecryptedString(new unsigned
+                char[fileSize]);
+        int count = 0;
+
+        do {
+            size_t readSize = fread(inChunk.get(), sizeof(unsigned char),
+                    readBufSize, fp);
+
+            if (0 != readSize) {
+                LogDebug("resource is encrypted. decrypting....");
+                using namespace Tizen::Base;
+                ByteBuffer *getBuffer =
+                    reinterpret_cast<ByteBuffer*>(DecryptChunkByTrustZone(inChunk.get(),
+                                readSize));
+                memcpy(DecryptedString.get() + (PLAIN_CHUNK_SIZE * count++),
+                        getBuffer->GetPointer(),
+                        (readSize < PLAIN_CHUNK_SIZE ? readSize : PLAIN_CHUNK_SIZE));
+                getBuffer->Reset();
+            }
 
+        } while( 0 == std::feof(fp));
         fclose(fp);
 
-        LogDebug("resource is encrypted. decrypting....");
-        unsigned char outDecBuf[bufSize];
-        memset(outDecBuf, 0, bufSize);
-        m_resDec->GetDecryptedChunk(contents, outDecBuf, bufSize);
-        memset(outDecBuf+size, '\n', bufSize - size);
-
+        memset(DecryptedString.get() + size, '\n', fileSize - size);
         LogDebug("resource need to encoding base64");
         BIO *bmem, *b64;
         BUF_MEM *bptr;
@@ -918,11 +931,11 @@ std::string Bundle::DecryptResource(std::string resource, int size)
         b64 = BIO_new(BIO_f_base64());
         bmem = BIO_new(BIO_s_mem());
         b64 = BIO_push(b64, bmem);
-        BIO_write(b64, outDecBuf, bufSize);
+        BIO_write(b64, DecryptedString.get(), fileSize);
         BIO_flush(b64);
         BIO_get_mem_ptr(b64, &bptr);
 
-        std::string base64Enc((char *)bptr->data, bptr->length-1);
+        std::string base64Enc((char *)bptr->data, bptr->length - 1);
         BIO_free_all(b64);
 
         return base64Enc;
@@ -930,86 +943,53 @@ std::string Bundle::DecryptResource(std::string resource, int size)
     return std::string();
 }
 
-void Bundle::requestSuspend()
+void *Bundle::DecryptChunkByTrustZone(const unsigned char *inBuffer,
+        int inBufSize)
 {
-    LogDebug("Unregister callbacks");
-    FOREACH(page, m_pagesList)
-    {
-        WKBundlePageSetPageLoaderClient(*page,NULL);
-    }
+    using namespace Tizen::Base;
+    std::string pkgid(DPL::ToUTF8String(m_widgetTizenId));
+
+    const byte *b_pkgid = reinterpret_cast<const byte*>(pkgid.c_str());
+    ByteBuffer appInfo;
+    appInfo.Construct(pkgid.length());
+    appInfo.SetArray(b_pkgid, 0, pkgid.length());
+    appInfo.Flip();
+
+    Tizen::Security::Crypto::_TrustZoneService* pInstance;
+    pInstance = Tizen::Security::Crypto::_TrustZoneService::GetInstance();
+
+    ByteBuffer pBuf;
+    pBuf.Construct(inBufSize);
+    const byte *pByte = reinterpret_cast<const byte*>(inBuffer);
+    pBuf.SetArray(pByte, 0, inBufSize);
+    pBuf.Flip();
+
+    ByteBuffer *getBuffer = pInstance->_TrustZoneService::DecryptN(appInfo, pBuf);
+    return reinterpret_cast<void*>(getBuffer);
 }
 
-void Bundle::requestResume()
+extern "C"
 {
-    LogDebug("Register callbacks");
-    FOREACH(page, m_pagesList)
-    {
-        connectLoaderClientCallbacksToPage(*page);
-    }
-}
-
-void Bundle::connectLoaderClientCallbacksToPage(WKBundlePageRef page)
+WK_EXPORT
+void WKBundleInitialize(WKBundleRef bundle,
+                        WKTypeRef)
 {
-    LogDebug("");
+    DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-BUNDLE");
+    LogDebug("Bundle initialized");
 
-    WKBundlePageLoaderClient loaderClient = {
-        kWKBundlePageLoaderClientCurrentVersion,
-        this, /* clientinfo */
-        didStartProvisionalLoadForFrameCallback, /* didStartProvisionalLoadForFrame */
-        0, /* didReceiveServerRedirectForProvisionalLoadForFrame */
-        0, /* didFailProvisionalLoadWithErrorForFrame */
-        didCommitLoadForFrameCallback, /* didCommitLoadForFrame */
-        0, /* didFinishDocumentLoadForFrame */
-        0, /* didFinishLoadForFrame */
-        0, /* didFailLoadWithErrorForFrame */
-        0, /* didSameDocumentNavigationForFrame */
-        0, /* didReceiveTitleForFrame */
-        0, /* didFirstLayoutForFrame */
-        0, /* didFirstVisuallyNonEmptyLayoutForFrame */
-        didRemoveFrameFromHierarchyCallback, /* didRemoveFrameFromHierarchy */
-        0, /* didDisplayInsecureContentForFrame */
-        0, /* didRunInsecureContentForFrame */
-        0, /* didClearWindowObjectForFrame */
-        0, /* didCancelClientRedirectForFrame */
-        0, /* willPerformClientRedirectForFrame */
-        0, /* didHandleOnloadEventsForFrame */
-        0, /* didLayoutForFrame */
-        0, /* didNewFirstVisuallyNonEmptyLayout */
-        0, /* didDetectXSSForFrame */
-        0, /* shouldGoToBackForwardListItem */
-        0, /* globalObjectIsAvailableForFrame */
-        0, /* willDisconnectDOMWindowExtensionFromGlobalObject */
-        0, /* didReconnectDOMWindowExtensionToGlobalObject */
-        0, /* willDestroyGlobalObjectForDOMWindowExtension */
-        0, /* didFinishProgress */
-        0, /* shouldForceUniversalAccessFromLocalURL */
-    };
-    WKBundlePageSetPageLoaderClient(page, &loaderClient);
-}
+    DPL::Event::GetMainEventDispatcherInstance().ResetCrossEventCallHandler();
+    LogDebug("ResetCrossEventCallHandler()");
 
+    static Bundle s_bundle = Bundle(bundle);
 
-extern "C"
-{
-    WK_EXPORT
-    void WKBundleInitialize(WKBundleRef bundle,
-                            WKTypeRef)
-    {
-        DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-BUNDLE");
-        LogDebug("Bundle initialized");
-
-        DPL::Event::GetMainEventDispatcherInstance().ResetCrossEventCallHandler();
-        LogDebug("ResetCrossEventCallHandler()");
-
-        static Bundle s_bundle = Bundle(bundle);
-
-        WKBundleClient client = {
-            kWKBundleClientCurrentVersion,
-            &s_bundle,
-            &Bundle::didCreatePageCallback,
-            &Bundle::willDestroyPageCallback,
-            0, /* didInitializePageGroup */
-            &Bundle::didReceiveMessageCallback
-        };
-        WKBundleSetClient(bundle, &client);
+    WKBundleClient client = {
+        kWKBundleClientCurrentVersion,
+        &s_bundle,
+        &Bundle::didCreatePageCallback,
+        &Bundle::willDestroyPageCallback,
+        0,     /* didInitializePageGroup */
+        &Bundle::didReceiveMessageCallback
+    };
+    WKBundleSetClient(bundle, &client);
 }
 }
index 5b91ce4..9d93fca 100644 (file)
 #include <WKPageLoadTypes.h>
 #include <WKBundlePage.h>
 #include <dpl/string.h>
-#include <dpl/encryption/resource_decryption.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 
 extern "C" {
-    WK_EXPORT void WKBundleInitialize(WKBundleRef bundle, WKTypeRef);
+WK_EXPORT void WKBundleInitialize(WKBundleRef bundle, WKTypeRef);
 }
 
-class Bundle {
+class Bundle
+{
   public:
     Bundle(WKBundleRef bundle);
     ~Bundle();
 
     // WKBundleClient callback
     static void didCreatePageCallback(
-            WKBundleRef bundle,
-            WKBundlePageRef page,
-            const void* clientInfo);
+        WKBundleRef bundle,
+        WKBundlePageRef page,
+        const void* clientInfo);
     static void willDestroyPageCallback(
-            WKBundleRef bundle,
-            WKBundlePageRef page,
-            const void* clientInfo);
+        WKBundleRef bundle,
+        WKBundlePageRef page,
+        const void* clientInfo);
     static void didReceiveMessageCallback(
-            WKBundleRef,
-            WKStringRef messageName,
-            WKTypeRef messageBody,
-            const void *clientInfo);
+        WKBundleRef,
+        WKStringRef messageName,
+        WKTypeRef messageBody,
+        const void *clientInfo);
 
   private:
     WKStringRef m_uriChangedMessage;
@@ -72,54 +72,55 @@ class Bundle {
     std::string m_encodedBundle;
     std::string m_theme;
     std::set<JSGlobalContextRef> m_loadedContext;
+    JSGlobalContextRef m_willRemoveContext;
     bool m_encrypted;
-    WRTDecryptor::ResourceDecryptor *m_resDec;
     WrtDB::EncryptedFileList m_encryptedFiles;
     WrtDB::WidgetType m_widgetType;
+       bool m_initialized;
 
     // WKBundlePageResourceLoadClient callback
     static WKURLRequestRef willSendRequestForFrameCallback(
-            WKBundlePageRef,
-            WKBundleFrameRef,
-            uint64_t resourceIdentifier,
-            WKURLRequestRef request,
-            WKURLResponseRef,
-            const void *clientInfo);
+        WKBundlePageRef,
+        WKBundleFrameRef,
+        uint64_t resourceIdentifier,
+        WKURLRequestRef request,
+        WKURLResponseRef,
+        const void *clientInfo);
     static void didFinishLoadForResourceCallback(
-            WKBundlePageRef page,
-            WKBundleFrameRef frame,
-            uint64_t resourceIdentifier,
-            const void* clientInfo);
+        WKBundlePageRef page,
+        WKBundleFrameRef frame,
+        uint64_t resourceIdentifier,
+        const void* clientInfo);
 
     // WKBundlePageDidStartProvisionalLoadForFrame callback
     static void didStartProvisionalLoadForFrameCallback(
-            WKBundlePageRef page,
-            WKBundleFrameRef frame,
-            WKTypeRef* userData,
-            const void *clientInfo);
+        WKBundlePageRef page,
+        WKBundleFrameRef frame,
+        WKTypeRef* userData,
+        const void *clientInfo);
 
     // WKBundlePageDidRemoveFrameFromHierarchy callback
     static void didRemoveFrameFromHierarchyCallback(
-            WKBundlePageRef page,
-            WKBundleFrameRef frame,
-            WKTypeRef* userData,
-            const void *clientInfo);
+        WKBundlePageRef page,
+        WKBundleFrameRef frame,
+        WKTypeRef* userData,
+        const void *clientInfo);
 
     // WKBundlePageLoaderClient callback
     static void didCommitLoadForFrameCallback(
-            WKBundlePageRef page,
-            WKBundleFrameRef frame,
-            WKTypeRef*,
-            const void *clientInfo);
+        WKBundlePageRef page,
+        WKBundleFrameRef frame,
+        WKTypeRef*,
+        const void *clientInfo);
 
     // WKBundlePageDecidePolicyForNavigationActionCallback
     static WKBundlePagePolicyAction pageDecidePolicyForNavigationActionCallback(
-            WKBundlePageRef page,
-            WKBundleFrameRef frame,
-            WKBundleNavigationActionRef navigationAction,
-            WKURLRequestRef request,
-            WKTypeRef* userData,
-            const void* clientInfo);
+        WKBundlePageRef page,
+        WKBundleFrameRef frame,
+        WKBundleNavigationActionRef navigationAction,
+        WKURLRequestRef request,
+        WKTypeRef* userData,
+        const void* clientInfo);
 
     // WKBundlePageDecidePolicyForResponseCallback
     static WKBundlePagePolicyAction pageDecidePolicyForResponseCallback(
@@ -134,16 +135,16 @@ class Bundle {
     void didCreatePage(WKBundlePageRef page);
     void willDestroyPage(WKBundlePageRef page);
     void didReceiveMessage(
-            WKStringRef messageName,
-            WKTypeRef messageBody);
+        WKStringRef messageName,
+        WKTypeRef messageBody);
 
     // WKBundlePageResourceLoadClient
     WKURLRequestRef willSendRequestForFrame(WKURLRequestRef request);
     WKBundlePagePolicyAction pageDecidePolicyForNavigationAction(
-        WKBundlePageRef             page,
-        WKBundleFrameRef            frame,
+        WKBundlePageRef page,
+        WKBundleFrameRef frame,
         WKBundleNavigationActionRef navigationAction,
-        WKURLRequestRef             request,
+        WKURLRequestRef request,
         WKTypeRef*                  userData);
 
     // basic
@@ -157,14 +158,10 @@ class Bundle {
     std::string DecryptResource(std::string resource, int size);
 
     void fixWKMessageArgs(std::string & argScale,
-        std::string & argEncodedBundle, std::string & argTheme);
-
-    void requestSuspend();
-    void requestResume();
-
-    void connectLoaderClientCallbacksToPage(WKBundlePageRef page);
-
-
+                          std::string & argEncodedBundle,
+                          std::string & argTheme);
+    void *DecryptChunkByTrustZone(const unsigned char *inBuffer,
+                                 int inBufSize);
 };
 
 #endif /* WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_ */
old mode 100755 (executable)
new mode 100644 (file)
index f785375..2c4606f
@@ -30,9 +30,9 @@
 #include <dpl/string.h>
 #include <dpl/foreach.h>
 
-#include <appcore-common.h>
 #include <pcrecpp.h>
 #include <vconf.h>
+#include <sysman.h>
 #include <widget_model.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/wrt-dao-ro/vconf_config.h>
 #include <common/view_logic_password_support.h>
 #include <common/view_logic_security_support.h>
 #include <common/view_logic_security_origin_support.h>
+#include <common/view_logic_certificate_support.h>
 #include <common/view_logic_storage_support.h>
 #include <common/view_logic_uri_support.h>
 #include <common/view_logic_user_agent_support.h>
 #include <common/view_logic_vibration_support.h>
+#include <view_logic_authentication_challenge_support.h>
 #include <view_logic_scheme_support.h>
-#include <view_logic_filesystem_support.h>
 #include <view_logic_geolocation_support_webkit2.h>
 #include <view_logic_usermedia_support.h>
 #include <view_logic_web_notification_support.h>
-#include <view_logic_web_storage_support.h>
+
+#include <view_logic_certificate_confirm_support.h>
 #include "bundles/plugin_module_support.h"
 #include <popup-runner/PopupInvoker.h>
 
@@ -64,9 +66,7 @@
 #include <js_overlay_types.h>
 #include <i_runnable_widget_object.h>
 #include <profiling_util.h>
-#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>
 #include <wrt-commons/custom-handler-dao-rw/custom_handler_dao.h>
 #include <popup-runner/PopupInvoker.h>
 
@@ -74,7 +74,7 @@
 
 namespace {
 const char * const bundlePath = "/usr/lib/wrt-wk2-bundles/libwrt-wk2-bundle.so";
-const char * const uriBlockedMessageName = "uri_block_msg";
+const char * const uriBlockedMessageName = "uri_blocked_msg";
 const char * const uriChangedMessageName = "uri_changed_msg";
 const char * const URICHANGE_PLUGIN_STOP_ONLY = "plugin_stop_only";
 const char * const URICHANGE_PLUGIN_RESTART = "plugin_restart";
@@ -96,78 +96,95 @@ const char * const CERTIFICATE_CONFIRM_REQUEST_ASK_TITLE =
     "Certification Info";
 const char * const CERTIFICATE_CONFIRM_REQUEST_ASK_BODY =
     "This site's security certificate is not trusted! Do you acess this site?";
+
+const wchar_t* BACKGROUND_ENABLED = L"background_enabled";
 } // anonymous namespace
 
-std::map<const std::string, const Evas_Smart_Cb> ViewLogic::m_ewkCallbacksMap =
-{
-    {"load,started", &ViewLogic::loadStartedCallback},
-    {"load,finished", &ViewLogic::loadFinishedCallback},
-    {"title,changed", &ViewLogic::titleChangedCallback},
-    {"load,progress", &ViewLogic::loadProgressCallback},
-    {"load,progress,finished", &ViewLogic::loadProgressFinishedCallback},
-    {"process,crashed", &ViewLogic::processCrashedCallback},
+std::map<const std::string,
+         const Evas_Smart_Cb> ViewLogic::m_ewkCallbacksMap = {
+    { "load,started", &ViewLogic::loadStartedCallback },
+    { "load,finished", &ViewLogic::loadFinishedCallback },
+    { "title,changed", &ViewLogic::titleChangedCallback },
+    { "load,progress", &ViewLogic::loadProgressCallback },
+    { "load,progress,finished", &ViewLogic::loadProgressFinishedCallback },
+    { "process,crashed", &ViewLogic::processCrashedCallback },
     // WKPageUIClient
-    {"create,window", &ViewLogic::createWindowCallback},
-    {"close,window", &ViewLogic::closeWindowCallback},
+    { "create,window", &ViewLogic::createWindowCallback },
+    { "close,window", &ViewLogic::closeWindowCallback },
     // WKPagePolicyClient
-    {"policy,navigation,decide", &ViewLogic::policyNavigationDecideCallback},
-    {"policy,newwindow,decide", &ViewLogic::policyNewWindowDecideCallback},
-    {"policy,response,decide", &ViewLogic::pageResponseDecideCallback},
+    { "policy,navigation,decide", &ViewLogic::policyNavigationDecideCallback },
+    { "policy,newwindow,decide", &ViewLogic::policyNewWindowDecideCallback },
+    { "policy,response,decide", &ViewLogic::pageResponseDecideCallback },
     // WKPageContextMenuClient
-    {"contextmenu,customize", &ViewLogic::contextmenuCustomizeCallback},
+    { "contextmenu,customize", &ViewLogic::contextmenuCustomizeCallback },
     // WKPageFormClient
-    {"form,submit", &ViewLogic::formSubmitCallback},
+    { "form,submit", &ViewLogic::formSubmitCallback },
     // EWK Geolocation Callback
-    {"request,geolocation,permission", &ViewLogic::geolocationPermissionRequestCallback},
+    { "geolocation,permission,request",
+      &ViewLogic::geolocationPermissionRequestCallback },
     // EWK Notification Callback
-    {"notification,show", &ViewLogic::notificationShowCallback},
-    {"notification,cancel", &ViewLogic::notificationCancelCallback},
-    {"notification,permission,request", &ViewLogic::notificationPermissionRequestCallback},
-
-    {"database,quota,exceeded", &ViewLogic::databaseUsagePermissionRequestCallback},
-    {"filesystem,permission,request", &ViewLogic::fileSystemPermissionRequestCallback},
-    {"fullscreen,enterfullscreen", &ViewLogic::enterFullscreenCallback},
-    {"fullscreen,exitfullscreen", &ViewLogic::exitFullscreenCallback},
+    { "notification,show", &ViewLogic::notificationShowCallback },
+    { "notification,cancel", &ViewLogic::notificationCancelCallback },
+    { "notification,permission,request",
+      &ViewLogic::notificationPermissionRequestCallback },
+
+    { "fullscreen,enterfullscreen", &ViewLogic::enterFullscreenCallback },
+    { "fullscreen,exitfullscreen", &ViewLogic::exitFullscreenCallback },
     // IME Callback
     // when ime start to be showed on the webview,
     // this callback will be called
-    {"inputmethod,changed", &ViewLogic::imeChangedCallback},
+    { "inputmethod,changed", &ViewLogic::imeChangedCallback },
     // this callback will be called
     //  when ime finishes to be showed on the webview
     // "event_info" arg of this callback is always NULL point
     // if web content should know size of ime,
     //  use "inputmethod,changed" instead of this.
     //
-    {"editorclient,ime,opened", &ViewLogic::imeOpenedCallback},
+    { "editorclient,ime,opened", &ViewLogic::imeOpenedCallback },
     // when ime finished to be hidden,
     // this callback will be called
-    {"editorclient,ime,closed", &ViewLogic::imeClosedCallback},
+    { "editorclient,ime,closed", &ViewLogic::imeClosedCallback },
     // EWK Usermedia Callback
-    {"usermedia,permission,request", &ViewLogic::usermediaPermissionRequestCallback},
+    { "usermedia,permission,request",
+      &ViewLogic::usermediaPermissionRequestCallback },
     // Custom handlers
-    {"protocolhandler,registration,requested", &ViewLogic::protocolHandlerRegistrationCallback},
-    {"protocolhandler,isregistered", &ViewLogic::protocolHandlerIsRegisteredCallback},
-    {"protocolhandler,unregistration,requested", &ViewLogic::protocolHandlerUnregistrationCallback},
-    {"contenthandler,registration,requested", &ViewLogic::contentHandlerRegistrationCallback},
-    {"contenthandler,isregistered", &ViewLogic::contentHandlerIsRegisteredCallback},
-    {"contenthandler,unregistration,requested", &ViewLogic::contentHandlerUnregistrationCallback},
-    {"request,certificate,confirm", &ViewLogic::certificateConfirmRequestCallback}
+    { "protocolhandler,registration,requested",
+      &ViewLogic::protocolHandlerRegistrationCallback },
+    { "protocolhandler,isregistered",
+      &ViewLogic::protocolHandlerIsRegisteredCallback },
+    { "protocolhandler,unregistration,requested",
+      &ViewLogic::protocolHandlerUnregistrationCallback },
+    { "contenthandler,registration,requested",
+      &ViewLogic::contentHandlerRegistrationCallback },
+    { "contenthandler,isregistered",
+      &ViewLogic::contentHandlerIsRegisteredCallback },
+    { "contenthandler,unregistration,requested",
+      &ViewLogic::contentHandlerUnregistrationCallback },
+    { "request,certificate,confirm",
+      &ViewLogic::certificateConfirmRequestCallback },
+    { "authentication,challenge",
+      &ViewLogic::authenticationChallengeRequestCallback }
 };
 
-ViewLogic::ViewLogic():
+ViewLogic::ViewLogic() :
     m_ewkContext(0),
+    m_attachedToCustomHandlerDao(false),
     m_currentEwkView(0),
+    m_closedEwkView(NULL),
     m_window(NULL),
     m_model(0),
     m_cbs(new WRT::UserDelegates),
+    m_imeWidth(0),
+    m_imeHeight(0),
     m_isBackgroundReload(false),
+    m_isBackgroundSupport(false),
     m_appsSupport(new ViewModule::AppsSupport()),
-    m_vibrationSupport(new ViewModule::VibrationSupport()),
-    m_attachedToCustomHandlerDao(false)
+    m_vibrationSupport(new ViewModule::VibrationSupport())
 {
+    ApplicationLauncherSingleton::Instance().Touch();
 }
 
-ViewLogic::~ViewLogic ()
+ViewLogic::~ViewLogic()
 {
     detachFromCustomHandlersDao();
 }
@@ -175,44 +192,24 @@ ViewLogic::~ViewLogic ()
 bool ViewLogic::createWebView(Ewk_Context* context,
                               Evas_Object* window)
 {
-    LogDebug("");
-    initializeEwkContext(context);
-    Assert(NULL != m_ewkContext);
-    Assert(window);
-    m_window = window;
-    if(!createEwkView(evas_object_evas_get(m_window)))
-    {
+    LogDebug("enter");
+    if (!context || !window) {
         return false;
     }
-    return true;
-}
 
-void ViewLogic::destroyWebView()
-{
-    if (m_ewkContext) {
-        finalizeEwkContext();
+    // theme setting
+    const char *theme = elm_theme_get(NULL);
+    if (theme) {
+        m_theme = theme;
+        LogInfo("theme is " << m_theme);
     }
-}
 
-void ViewLogic::initialize()
-{
-    LogDebug("Initializing");
-    ApplicationLauncherSingleton::Instance().Touch();
-    appcore_set_event_callback(
-        APPCORE_EVENT_LOW_MEMORY,
-        &appcoreLowMemoryCallback,
-        this);
-}
+    // set members
+    m_ewkContext = context;
+    m_window = window;
 
-void ViewLogic::terminate()
-{
-    LogDebug("terminating view logic");
-    if (m_model) {
-        hideWidget();
-    } else {
-        LogError("Widget model not created");
-    }
-    LogDebug("done");
+    Evas* canvas = evas_object_evas_get(m_window);
+    return createEwkView(canvas);
 }
 
 void ViewLogic::prepareView(WidgetModel* m, const std::string &startUrl)
@@ -221,7 +218,7 @@ void ViewLogic::prepareView(WidgetModel* m, const std::string &startUrl)
 
     Assert(m);
     m_model = m;
-    m_startUrl = ViewModule::UriSupport::getUri(m_model, startUrl);
+    m_startUrl = startUrl;
     Assert(NULL != m_ewkContext);
     Assert(m_window);
 
@@ -263,44 +260,25 @@ void ViewLogic::hideWidget()
 
     m_vibrationSupport->deinitialize();
 
-    while (m_ewkViewList.size()) {
+    while (!m_ewkViewList.empty()) {
         LogInfo("pop webview: " << m_ewkViewList.back());
         removeEwkView(m_ewkViewList.back());
     }
     m_ewkViewList.clear();
 }
 
-void ViewLogic::changeViewVisibility(bool isVisible)
-{
-    Evas_Object* wkView = m_currentEwkView;
-    if (!wkView)
-        return;
-
-    if (isVisible) {
-        ewk_view_page_visibility_state_set(wkView,
-                                           EWK_PAGE_VISIBILITY_STATE_VISIBLE,
-                                           EINA_FALSE);
-        ewk_view_visibility_set(wkView, EINA_TRUE);
-    } else {
-        ewk_view_page_visibility_state_set(wkView,
-                                           EWK_PAGE_VISIBILITY_STATE_HIDDEN,
-                                           EINA_FALSE);
-        ewk_view_visibility_set(wkView, EINA_FALSE);
-    }
-}
-
 void ViewLogic::suspendWidget()
 {
     LogInfo("Pausing widget");
     Assert(m_model);
 
-    LogDebug("Request bundle to suspend");
-    PluginModuleSupport::suspend(m_ewkContext);
-
     if (!m_currentEwkView) {
         LogWarning("Cannot suspend widget without view");
     } else {
-        suspendWebkit(m_currentEwkView);
+        setEwkViewInvisible(m_currentEwkView);
+        if (!m_isBackgroundSupport) {
+            suspendWebkit(m_currentEwkView);
+        }
     }
 
     evas_object_focus_set(m_currentEwkView, EINA_FALSE);
@@ -309,40 +287,40 @@ void ViewLogic::suspendWidget()
     if (!m_cbs->suspend.empty()) {
         m_cbs->suspend(true);
     }
-};
+}
 
 void ViewLogic::resumeWidget()
 {
     LogInfo("Resume widget");
     Assert(m_model);
 
-    LogDebug("Request bundle to resume");
-    PluginModuleSupport::resume(m_ewkContext);
-
     if (m_currentEwkView) {
-        resumeWebkit(m_currentEwkView);
+        setEwkViewVisible(m_currentEwkView);
+        if (!m_isBackgroundSupport) {
+            resumeWebkit(m_currentEwkView);
+        }
     }
 
-   /* window system team recomend removing this win_raise code. */
+    /* window system team recomend removing this win_raise code. */
     /*
-    if (m_window) {
-        elm_win_raise(m_window);
-    }
-    */
+     * if (m_window) {
+     *  elm_win_raise(m_window);
+     * }
+     */
     evas_object_focus_set(m_currentEwkView, EINA_TRUE);
 
     // call user callback
     if (!m_cbs->resume.empty()) {
         m_cbs->resume(true);
     }
-};
+}
 
 void ViewLogic::resetWidget()
 {
     LogInfo("Resetting Widget");
 
     // destory all webview
-    while (m_ewkViewList.size()) {
+    while (!m_ewkViewList.empty()) {
         LogInfo("pop webview: " << m_ewkViewList.back());
         removeEwkView(m_ewkViewList.back());
     }
@@ -356,7 +334,7 @@ void ViewLogic::resetWidget()
 
     // check if current url is service url for this tizen service
     std::string requestedUri =
-            ViewModule::UriSupport::getUri(m_model, m_startUrl);
+        ViewModule::UriSupport::getUri(m_model, m_startUrl);
     DPL::OptionalString servicedUri = ViewModule::UriSupport::localizeURI(
             DPL::FromUTF8String(requestedUri.c_str()),
             m_model);
@@ -364,7 +342,6 @@ void ViewLogic::resetWidget()
     initializePluginLoading();
 
     // webview activated
-    PluginModuleSupport::resume(m_ewkContext);
     m_currentUri = DPL::ToUTF8String(*servicedUri);
     ewk_view_url_set(m_currentEwkView, m_currentUri.c_str());
     elm_win_activate(m_window);
@@ -402,10 +379,9 @@ void ViewLogic::reloadStartPage()
     LogInfo("Reload Start Page");
     // prevent fail to load plugin bundle side
     m_isBackgroundReload = true;
-    PluginModuleSupport::resume(m_ewkContext);
 
-    if (m_ewkViewList.size() != 0) {
-        while (m_ewkViewList.size() > 0) {
+    if (!m_ewkViewList.empty()) {
+        while (!m_ewkViewList.empty()) {
             if (!m_cbs->bufferUnset.empty()) {
                 m_cbs->bufferUnset(m_currentEwkView);
             }
@@ -450,99 +426,88 @@ void ViewLogic::setUserCallbacks(const WRT::UserDelegatesPtr& cbs)
     m_cbs = cbs;
 }
 
-void ViewLogic::initializeEwkContext(Ewk_Context* newEwkContext)
+void ViewLogic::checkSyncMessageFromBundle(
+        const char* name,
+        const char* body,
+        char** returnData)
 {
-    LogInfo("initializeEwkContext called");
-    Assert(newEwkContext && "Ewk_Context provided can not be null");
-    // bundle callback setting
-    ewk_context_message_from_injected_bundle_callback_set(
-        newEwkContext,
-        contextMessageFromInjectedBundleCallback,
-        static_cast<void*>(this));
-
-    // proxy server setting
-    char *proxyAddress = vconf_get_str(VCONFKEY_NETWORK_PROXY);
-    if ((!proxyAddress) || (strlen(proxyAddress) == 0)
-        || (strstr(proxyAddress, "0.0.0.0")))
-    {
-        LogInfo("proxy address is empty");
-        ewk_context_proxy_uri_set(newEwkContext, NULL);
-    } else {
-        LogInfo("proxy address [" << proxyAddress << "]");
-        ewk_context_proxy_uri_set(newEwkContext,  proxyAddress);
-    }
+    LogDebug("didReceiveSynchronousMessage called");
+    Assert(name);
+    Assert(returnData);
 
-    if (proxyAddress) {
-        free(proxyAddress);
-        proxyAddress = NULL;
+    if (!body) {
+        LogDebug("body is empty");
+        *returnData = NULL;
+        return;
     }
 
-    // theme setting
-    const char *theme = elm_theme_get(NULL);
-    if (theme) {
-        m_theme = theme;
-        LogInfo("theme is " << m_theme);
+    LogDebug("received : " << name);
+    std::string result;
+    if (!strcmp(name, uriBlockedMessageName)) {
+        // Currently WebProcess informs obly about blocked
+        // URI - URI localization and security chekcs are
+        // done by WebProcess itself (see: wrt-wk2-bundle.cpp
+        // and bundle_uri_handling.cpp)
+        result = requestUrlBlocked(std::string(body));
+    } else if (!strcmp(name, uriChangedMessageName)) {
+        result = requestUrlChanged(std::string(body));
     }
 
-    // Ewk download callback (WKContextDownloadClient)
-    ewk_context_did_start_download_callback_set(
-        newEwkContext,
-        didStartDownloadCallback,
-        this);
-
-    ewk_context_vibration_client_callbacks_set(
-        newEwkContext,
-        vibrationVibrateCallback,
-        vibrationCancelCallback,
-        this);
+    *returnData = strdup(result.c_str());
+}
 
-    ewk_context_certificate_file_set(m_ewkContext,
-        "/opt/usr/share/certs/ca-certificate.crt");
+void ViewLogic::downloadData(const char* url)
+{
+    LogInfo("enter");
+    if (!url) {
+        return;
+    }
 
-    // set to member value
-    m_ewkContext = newEwkContext;
+    m_appsSupport->downloadRequest(url, NULL, NULL);
 }
 
-void ViewLogic::finalizeEwkContext()
+void ViewLogic::activateVibration(bool on, uint64_t time)
 {
-    LogInfo("finalizeEwkContext called");
-    ewk_context_message_from_injected_bundle_callback_set(
-            m_ewkContext,
-            NULL,
-            NULL);
-    ewk_context_did_start_download_callback_set(
-            m_ewkContext,
-            NULL,
-            NULL);
-    ewk_context_vibration_client_callbacks_set(
-            m_ewkContext,
-            NULL,
-            NULL,
-            NULL);
-//    ewk_context_delete(m_ewkContext);
-//    m_ewkContext = 0;
+    LogInfo("enter");
+    if (on) {
+        m_vibrationSupport->startVibration(static_cast<long>(time));
+    } else {
+        m_vibrationSupport->stopVibration();
+    }
 }
 
 void ViewLogic::initializeSupport()
 {
-    // set local stroage database path
-    WrtDB::WidgetDAOReadOnly dao(m_model->TizenId);
-    ewk_context_web_storage_path_set(m_ewkContext,
-                                     dao.getPrivateLocalStoragePath().c_str());
-    // memory saving mode
-    int result;
-    vconf_get_int(
-        WrtDB::VconfConfig::GetVconfKeyMemorySavingMode(
-            m_model->TizenId).c_str(),
-        &result);
-    ewk_context_memory_saving_mode_set(
-        m_ewkContext,
-        static_cast<WrtDB::SettingsType>(result) ==
-            WrtDB::SETTINGS_TYPE_ON ? EINA_TRUE : EINA_FALSE);
+    // background support
+    if (m_model->SettingList.Get().getBackgroundSupport()
+        == BackgroundSupport_Enable)
+    {
+        LogDebug("Background support enabled, set process active");
+        pid_t pid = getpid();
+        sysman_inform_active(pid);
+        m_isBackgroundSupport = true;
+    }
+#ifndef DEPRECATED_SETTING_STRING
+    else {
+        WrtDB::WidgetDAOReadOnly dao(m_model->TizenId);
+        WrtDB::PropertyDAOReadOnly::WidgetPropertyValue bgEnableValue =
+            dao.getPropertyValue(DPL::String(BACKGROUND_ENABLED));
+
+        if (!bgEnableValue.IsNull() && !bgEnableValue->compare(L"true")) {
+            //skip suspendWidget
+            LogDebug("Background support enabled, set process active");
+            pid_t pid = getpid();
+            sysman_inform_active(pid);
+            m_isBackgroundSupport = true;
+        }
+    }
+#endif
+
     m_schemeSupport.reset(new SchemeSupport(m_model->Type.Get().appType));
     ViewModule::StorageSupport::initializeStorage(m_model);
     m_appsSupport->initialize(m_model);
     m_securityOriginSupport.reset(new ViewModule::SecurityOriginSupport(m_model));
+    m_certificateSupport.reset(new ViewModule::CertificateSupport(m_model));
 
     m_vibrationSupport->initialize();
 }
@@ -559,28 +524,41 @@ void ViewLogic::initializePluginLoading()
         m_model->SettingList.Get().isEncrypted());
 }
 
-void ViewLogic::ewkClientInit(Evas_Object *wkView) {
+void ViewLogic::ewkClientInit(Evas_Object *wkView)
+{
     Assert(NULL != wkView && "ewk_view not created at this point");
 
-    FOREACH(it, m_ewkCallbacksMap) {
+    FOREACH(it, m_ewkCallbacksMap)
+    {
         evas_object_smart_callback_add(
             wkView,
             it->first.c_str(),
             it->second,
             this);
     }
+    // EWK Orientation Callback
+    ewk_view_orientation_lock_callback_set(
+        wkView,
+        orientationLockCallback,
+        this);
 }
 
-void ViewLogic::ewkClientDeinit(Evas_Object *wkView) {
+void ViewLogic::ewkClientDeinit(Evas_Object *wkView)
+{
     LogDebug("ewkClientDeinit");
     Assert(NULL != wkView && "ewk_view not created at this point");
 
-    FOREACH(it, m_ewkCallbacksMap) {
+    FOREACH(it, m_ewkCallbacksMap)
+    {
         evas_object_smart_callback_del(
             wkView,
             it->first.c_str(),
             it->second);
     }
+    ewk_view_orientation_lock_callback_set(
+        wkView,
+        NULL,
+        NULL);
 }
 
 bool ViewLogic::createEwkView(Evas* canvas)
@@ -589,14 +567,14 @@ bool ViewLogic::createEwkView(Evas* canvas)
     Assert(canvas);
     ADD_PROFILING_POINT("ewk_view_add_with_context", "start");
     Evas_Object* newEwkView = ewk_view_add_with_context(
-        canvas,
-        m_ewkContext);
+            canvas,
+            m_ewkContext);
     ADD_PROFILING_POINT("ewk_view_add_with_context", "stop");
 
     if (!newEwkView) {
         LogError("View creation failed");
         Wrt::Popup::PopupInvoker().showInfo(
-                "Info", "View creation failed","close");
+            "Info", "View creation failed", "close");
         return false;
     }
 
@@ -607,7 +585,11 @@ bool ViewLogic::createEwkView(Evas* canvas)
     ewkCookieManager =
         ewk_context_cookie_manager_get(m_ewkContext);
     ewk_cookie_manager_accept_policy_set(ewkCookieManager,
-                           EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+                                         EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+
+    if (m_currentEwkView) {
+        setEwkViewInvisible(m_currentEwkView);
+    }
 
     LogInfo("push webview: " << newEwkView);
     m_ewkViewList.push_back(newEwkView);
@@ -619,13 +601,50 @@ void ViewLogic::setStartPage()
 {
     /* Start URI (as other uris) is now localized
      * on WebProcess side */
-    m_currentUri = m_startUrl;
+    m_currentUri = ViewModule::UriSupport::getUri(m_model, m_startUrl);
 }
 
 void ViewLogic::prepareEwkView(Evas_Object *wkView)
 {
     LogDebug("prepareEwkView called");
     Assert(wkView);
+
+#ifdef CSP_ENABLED
+    LogInfo("Setting CSP default policy");
+    ewk_context_tizen_extensible_api_set(
+        m_ewkContext, EWK_EXTENSIBLE_API_CSP, true);
+    // setting CSP policy rules
+    // temporary turn off
+    //ewk_view_content_security_policy_set(
+    //    wkView,
+    //    "default-src '*'; script-src 'self'; style-src 'self'; object-src 'none';",
+    //    EWK_ENFORCE_POLICY);
+    //LogInfo("Default policy set");
+
+    DPL::OptionalString policy = m_model->CspPolicy.Get();
+
+    if (!(policy.IsNull()))
+    {
+        LogDebug("CSP policy present in manifest: " << *policy);
+        ewk_view_content_security_policy_set(
+            wkView, DPL::ToUTF8String(*policy).c_str(), EWK_ENFORCE_POLICY);
+    } else {
+        LogDebug("Config CSP policy is not present");
+    }
+
+    policy = m_model->CspReportOnlyPolicy.Get();
+    if (!(policy.IsNull()))
+    {
+        LogDebug("CSP report only policy present in manifest: " << *policy);
+        ewk_view_content_security_policy_set(
+            wkView, DPL::ToUTF8String(*policy).c_str(), EWK_REPORT_ONLY);
+    } else {
+        LogDebug("Config CSP report only policy is not present");
+    }
+
+    LogInfo("CSP set.");
+#endif
+
     Ewk_Settings* settings = ewk_view_settings_get(wkView);
 
     // set user agent
@@ -659,13 +678,16 @@ void ViewLogic::prepareEwkView(Evas_Object *wkView)
     // The followings are not implemeted yet by webkit2
     //      ewk_view_setting_accelerated_compositing_enable_set(EINA_TRUE);
     //      ewk_view_mode_set();
-    //      ewk_view_setting_enable_specified_plugin_set(EINA_TRUE, FLASH_MIME_TYPE);
+    //      ewk_view_setting_enable_specified_plugin_set(EINA_TRUE,
+    // FLASH_MIME_TYPE);
     //      ewk_view_setting_html5video_external_player_enable_set(EINA_FALSE);
     //      ewk_view_show_ime_on_autofocus_set(EINA_TRUE);
     //      elm_webview_show_magnifier_set(EINA_FALSE);
     ewk_settings_javascript_enabled_set(settings, EINA_TRUE);
     ewk_settings_loads_images_automatically_set(settings, EINA_TRUE);
-    ewk_settings_auto_fitting_set(settings, EINA_TRUE);
+    // WRT should not fit web contents to device width automatically as default.
+    // Fitting to device width should be handled by web content using viewport meta tag.
+    ewk_settings_auto_fitting_set(settings, EINA_FALSE);
 
     // disable zoom option when user click the input field
     // this option is useful with the normal website
@@ -724,10 +746,31 @@ void ViewLogic::suspendEwkView(Evas_Object *wkView)
 
     // unregister webview callbacks
     ewkClientDeinit(wkView);
-
     return;
 }
 
+void ViewLogic::setEwkViewInvisible(Evas_Object *wkView)
+{
+    LogInfo("setEwkViewInvisible called");
+    Assert(wkView);
+
+    ewk_view_page_visibility_state_set(wkView,
+                                       EWK_PAGE_VISIBILITY_STATE_HIDDEN,
+                                       EINA_FALSE);
+    ewk_view_visibility_set(wkView, EINA_FALSE);
+}
+
+void ViewLogic::setEwkViewVisible(Evas_Object *wkView)
+{
+    LogInfo("setEwkViewVisible called");
+    Assert(wkView);
+
+    ewk_view_page_visibility_state_set(wkView,
+                                       EWK_PAGE_VISIBILITY_STATE_VISIBLE,
+                                       EINA_FALSE);
+    ewk_view_visibility_set(wkView, EINA_TRUE);
+}
+
 void ViewLogic::resumeWebkit(Evas_Object *wkView)
 {
     LogDebug("resumeWebkit");
@@ -741,10 +784,7 @@ void ViewLogic::resumeWebkit(Evas_Object *wkView)
     //      ewk_view_enable_render();
     //      ewk_view_reduce_plugins_frame_rate(false);
     ewk_view_resume(wkView);
-    ewk_view_visibility_set(wkView, EINA_TRUE);
-    ewk_view_page_visibility_state_set(wkView,
-                                       EWK_PAGE_VISIBILITY_STATE_VISIBLE,
-                                       EINA_FALSE);
+
     return;
 }
 
@@ -762,49 +802,10 @@ void ViewLogic::suspendWebkit(Evas_Object *wkView)
     return;
 }
 
-void ViewLogic::contextMessageFromInjectedBundleCallback(
-        const char* name,
-        const char* body,
-        char** returnData,
-        void* clientInfo)
-{
-    LogDebug("contextMessageFromInjectedBundleCallback called");
-    Assert(clientInfo);
-    ViewLogic* This = static_cast<ViewLogic*>(clientInfo);
-    // didRecieveMessageFromInjectedBundleCallback - returnData is null
-    // didReceiveSynchronousMessageCallback - returnData isn't null
-    // WKContextInjectedBundleClient bundleClient = {
-    //     kWKContextInjectedBundleClientCurrentVersion,
-    //     static_cast<void*>(this),
-    //     &didRecieveMessageFromInjectedBundleCallback,
-    //     &didReceiveSynchronousMessageCallback
-    // };
-    if (NULL == returnData) {
-        This->didRecieveMessageFromInjectedBundle(name, body);
-    } else {
-        This->didReceiveSynchronousMessage(name, body, returnData);
-    }
-}
-
-void ViewLogic::didStartDownloadCallback(
-        const char* downloadUrl,
-        void* data)
-{
-    LogDebug("didStartDownloadCallback called");
-    Assert(data);
-    ViewLogic* This = static_cast<ViewLogic*>(data);
-    Assert(downloadUrl);
-    LogDebug("download url = " << downloadUrl);
-    This->m_appsSupport->downloadRequest(
-        downloadUrl,
-        NULL,
-        NULL);
-}
-
 void ViewLogic::loadStartedCallback(
-        void* data,
-        Evas_Object* obj,
-        void* /*eventInfo*/)
+    void* data,
+    Evas_Object* obj,
+    void* /*eventInfo*/)
 {
     LogDebug("loadStartedCallback called");
     Assert(data);
@@ -815,13 +816,12 @@ void ViewLogic::loadStartedCallback(
     if (!This->m_cbs->loadStart.empty()) {
         This->m_cbs->loadStart(obj);
     }
-
 }
 
 void ViewLogic::loadFinishedCallback(
-        void* data,
-        Evas_Object* obj,
-        void* /*eventInfo*/)
+    void* data,
+    Evas_Object* obj,
+    void* /*eventInfo*/)
 {
     LogDebug("loadFinishedCallback called");
     Assert(data);
@@ -831,22 +831,39 @@ void ViewLogic::loadFinishedCallback(
     const char* url = ewk_view_url_get(This->m_currentEwkView);
     if (NULL == url || strlen(url) == 0) {
         LogError("url is empty");
-    } else {
-        DPL::OptionalString jsOptionalString =
-            ViewModule::PasswordSupport::jsForAutoFillData(url);
-        if (jsOptionalString.IsNull()) {
-            LogError("Fail to get JS String");
+        return;
+    }
+
+    // check if this loading is for blocked url
+    if (This->m_blockedUri == url) {
+        if (ewk_view_back_possible(This->m_currentEwkView)) {
+            // go back to previous page
+            LogDebug("go to previous page");
+            ewk_view_back(This->m_currentEwkView);
         } else {
-            std::string jsStr = DPL::ToUTF8String(*jsOptionalString).c_str();
+            // stop current page
+            LogDebug("remove current page");
+            ewk_view_stop(This->m_currentEwkView);
+            ecore_idler_add(windowCloseIdlerCallback, This);
+        }
+        This->m_blockedUri = std::string();
+        return;
+    }
+
+    DPL::OptionalString jsOptionalString =
+        ViewModule::PasswordSupport::jsForAutoFillData(url);
+    if (jsOptionalString.IsNull()) {
+        LogError("Fail to get JS String");
+    } else {
+        std::string jsStr = DPL::ToUTF8String(*jsOptionalString).c_str();
 
-            if(EINA_FALSE == ewk_view_script_execute(
+        if (EINA_FALSE == ewk_view_script_execute(
                 This->m_currentEwkView,
                 jsStr.c_str(),
                 didRunJavaScriptCallback,
                 This))
-            {
-                LogError("JS for auto fill data failed.");
-            }
+        {
+            LogError("JS for auto fill data failed.");
         }
     }
 
@@ -871,16 +888,15 @@ void ViewLogic::loadFinishedCallback(
     // In this case, widget is reloaded in the background.
     // After finished load, bundle should disconnent callback.
     if (This->m_isBackgroundReload) {
-        PluginModuleSupport::suspend(This->m_ewkContext);
         ewk_view_suspend(This->m_currentEwkView);
         This->m_isBackgroundReload = false;
     }
 }
 
 void ViewLogic::titleChangedCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* obj,
+    void* eventInfo)
 {
     LogDebug("titleChangedCallback called");
     Assert(data);
@@ -890,27 +906,39 @@ void ViewLogic::titleChangedCallback(
 
     if (0 == strlen(title)) {
         LogDebug("title data is empty");
+        This->m_currentTitle = std::string();
         return;
     }
     LogDebug("Title = [" << title << "]");
-    This->m_schemeSupport->HandleTizenScheme(title,
+    bool ret = This->m_schemeSupport->HandleTizenScheme(
+                                             title,
                                              This->m_window,
                                              This->m_currentEwkView);
+    // if result is true, this is tizen scheme
+    // and then, title is reset to page's real title
+    if (ret) {
+        std::string script = "document.title = \"";
+        script += This->m_currentTitle;
+        script +="\";";
+        ewk_view_script_execute(obj, script.c_str(), didRunJavaScriptCallback, This);
+    } else {
+        This->m_currentTitle = std::string(title);
+    }
 }
 
 void ViewLogic::loadProgressCallback(
-        void* /*data*/,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* /*data*/,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     double* progress = static_cast<double*>(eventInfo);
     LogDebug("didChangeProgressCallback progress = " << *progress);
 }
 
 void ViewLogic::loadProgressFinishedCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* /*eventInfo*/)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* /*eventInfo*/)
 {
     LogDebug("didFinishProgressCallback");
     Assert(data);
@@ -921,14 +949,14 @@ void ViewLogic::loadProgressFinishedCallback(
 }
 
 void ViewLogic::processCrashedCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogInfo("processCrashedCallback");
     Assert(data);
     ViewLogic const * const view =
-            static_cast<ViewLogic const * const>(data);
+        static_cast<ViewLogic const * const>(data);
     if (!view->m_cbs->webCrash.empty()) {
         view->m_cbs->webCrash();
     }
@@ -939,9 +967,9 @@ void ViewLogic::processCrashedCallback(
 }
 
 void ViewLogic::createWindowCallback(
-        void* data,
-        Evas_Object* obj,
-        void* eventInfo)
+    void* data,
+    Evas_Object* obj,
+    void* eventInfo)
 {
     LogDebug("createWindowCallback");
     Assert(data);
@@ -985,9 +1013,9 @@ void ViewLogic::createWindowCallback(
 }
 
 void ViewLogic::closeWindowCallback(
-        void* data,
-        Evas_Object* obj,
-        void* /*eventInfo*/)
+    void* data,
+    Evas_Object* obj,
+    void* /*eventInfo*/)
 {
     LogDebug("closeWindowCallback");
     ViewLogic* This = static_cast<ViewLogic*>(data);
@@ -996,9 +1024,9 @@ void ViewLogic::closeWindowCallback(
 }
 
 void ViewLogic::policyNavigationDecideCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogDebug("policyNavigationDecideCallback called");
     Assert(data);
@@ -1018,7 +1046,7 @@ void ViewLogic::policyNavigationDecideCallback(
     } else {
         // check whether this is new empty window
         const char* activeUrl = ewk_view_url_get(This->m_currentEwkView);
-        if(!activeUrl || 0 == strlen(activeUrl)) {
+        if (!activeUrl || 0 == strlen(activeUrl)) {
             /*
              * The view is empty and scheme has been handled externally. When
              * user gets back from the external application he'd see blank page
@@ -1047,9 +1075,9 @@ void ViewLogic::policyNavigationDecideCallback(
 }
 
 void ViewLogic::policyNewWindowDecideCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogDebug("policyNewWindowDecideCallback called");
     Assert(data);
@@ -1072,9 +1100,9 @@ void ViewLogic::policyNewWindowDecideCallback(
 }
 
 void ViewLogic::pageResponseDecideCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogDebug("pageResponseDecideCallback called");
     Assert(data);
@@ -1093,7 +1121,7 @@ void ViewLogic::pageResponseDecideCallback(
         ewk_policy_decision_suspend(policyDecision);
 
         // get uri information
-        const char* url =  ewk_policy_decision_url_get(policyDecision);
+        const char* url = ewk_policy_decision_url_get(policyDecision);
         if (NULL == url || strlen(url) == 0) {
             LogDebug("url data is empty");
             ewk_policy_decision_use(policyDecision);
@@ -1126,9 +1154,9 @@ void ViewLogic::pageResponseDecideCallback(
 }
 
 void ViewLogic::contextmenuCustomizeCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogDebug("contextmenuCustomizeCallback called");
     Assert(data);
@@ -1137,20 +1165,22 @@ void ViewLogic::contextmenuCustomizeCallback(
     Ewk_Context_Menu* menu = static_cast<Ewk_Context_Menu*>(eventInfo);
     if ((This->m_model->Type.Get().appType == WrtDB::APP_TYPE_TIZENWEBAPP) &&
         (This->m_model->SettingList.Get().getContextMenu()
-            == ContextMenu_Disable))
+         == ContextMenu_Disable))
     {
         LogDebug("ContextMenu Disable!!");
         for (unsigned int idx = 0; idx < ewk_context_menu_item_count(menu);) {
-            Ewk_Context_Menu_Item* item = ewk_context_menu_nth_item_get(menu, idx);
+            Ewk_Context_Menu_Item* item = ewk_context_menu_nth_item_get(menu,
+                                                                        idx);
             Assert(item);
             ewk_context_menu_item_remove(menu, item);
         }
     } else {
         LogDebug("ContextMenu Enable!!");
-        int menu_num = ewk_context_menu_item_count(menu);
+        unsigned int menu_num = ewk_context_menu_item_count(menu);
         unsigned int idx = 0;
         do {
-            Ewk_Context_Menu_Item* item = ewk_context_menu_nth_item_get(menu, idx);
+            Ewk_Context_Menu_Item* item = ewk_context_menu_nth_item_get(menu,
+                                                                        idx);
             if (!item) {
                 idx++;
                 continue;
@@ -1158,38 +1188,38 @@ void ViewLogic::contextmenuCustomizeCallback(
             Ewk_Context_Menu_Item_Tag tag = ewk_context_menu_item_tag_get(item);
 
             switch (tag) {
-                case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW:
-                    ewk_context_menu_item_remove(menu, item);
-                    continue;
+            case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW:
+                ewk_context_menu_item_remove(menu, item);
+                continue;
 
-                case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW:
-                    ewk_context_menu_item_remove(menu, item);
-                    continue;
+            case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW:
+                ewk_context_menu_item_remove(menu, item);
+                continue;
 
-                case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_FRAME_IN_NEW_WINDOW:
-                    ewk_context_menu_item_remove(menu, item);
-                    continue;
+            case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_FRAME_IN_NEW_WINDOW:
+                ewk_context_menu_item_remove(menu, item);
+                continue;
 
-                case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_MEDIA_IN_NEW_WINDOW:
-                    ewk_context_menu_item_remove(menu, item);
-                    continue;
+            case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_MEDIA_IN_NEW_WINDOW:
+                ewk_context_menu_item_remove(menu, item);
+                continue;
 
-                case EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB:
-                    ewk_context_menu_item_remove(menu, item);
-                    continue;
+            case EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB:
+                ewk_context_menu_item_remove(menu, item);
+                continue;
 
-                default:
-                    idx++;
-                    break;
+            default:
+                idx++;
+                break;
             }
         } while (idx < menu_num);
     }
 }
 
 void ViewLogic::formSubmitCallback(
-        void* /*data*/,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* /*data*/,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogDebug("formSubmitCallback called");
     Assert(eventInfo);
@@ -1206,23 +1236,21 @@ void ViewLogic::formSubmitCallback(
 }
 
 void ViewLogic::geolocationPermissionRequestCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
     Assert(eventInfo);
-    Ewk_Geolocation_Permission_Data* permissionRequest =
-         static_cast<Ewk_Geolocation_Permission_Data*>(eventInfo);
+    Ewk_Geolocation_Permission_Request* permissionRequest =
+        static_cast<Ewk_Geolocation_Permission_Request*>(eventInfo);
 
     if (This->m_securityOriginSupport->isNeedPermissionCheck(
-        SecurityOriginDB::FEATURE_GEOLOCATION)
+            SecurityOriginDB::FEATURE_GEOLOCATION)
         == WrtDB::SETTINGS_TYPE_OFF)
     {
-        ewk_geolocation_permission_request_allow_set(
-            ewk_geolocation_permission_request_get(permissionRequest),
-            EINA_FALSE);
+        ewk_geolocation_permission_request_set(permissionRequest, EINA_FALSE);
         return;
     }
     ViewModule::GeolocationSupport::Webkit2::geolocationPermissionRequest(
@@ -1232,9 +1260,9 @@ void ViewLogic::geolocationPermissionRequestCallback(
 }
 
 void ViewLogic::notificationShowCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogDebug("notificationShowCallback called");
     Assert(data);
@@ -1246,9 +1274,9 @@ void ViewLogic::notificationShowCallback(
     using namespace ViewModule::WebNotification;
 
     WebNotificationDataPtr notiData(
-            new WebNotificationData(
-                This->m_model,
-                ewk_notification_id_get(noti)));
+        new WebNotificationData(
+            This->m_model,
+            ewk_notification_id_get(noti)));
 
     DPL::OptionalString string =
         DPL::FromUTF8String(ewk_notification_icon_url_get(noti));
@@ -1274,29 +1302,28 @@ void ViewLogic::notificationShowCallback(
 }
 
 void ViewLogic::notificationCancelCallback(
-        void* /*data*/,
-        Evas_Object* /*obj*/,
-        void* /*eventInfo*/)
+    void* /*data*/,
+    Evas_Object* /*obj*/,
+    void* /*eventInfo*/)
 {
     LogDebug("notificationCancelCallback called");
 }
 
 void ViewLogic::notificationPermissionRequestCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogDebug("notificationPermissionRequestCallback called");
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
     if (This->m_securityOriginSupport->isNeedPermissionCheck(
-        SecurityOriginDB::FEATURE_WEB_NOTIFICATION)
+            SecurityOriginDB::FEATURE_WEB_NOTIFICATION)
         == WrtDB::SETTINGS_TYPE_OFF)
     {
         Ewk_Notification_Permission_Request* request =
             static_cast<Ewk_Notification_Permission_Request*>(eventInfo);
-        ewk_notification_permission_request_response(
-            This->m_ewkContext,
+        ewk_notification_permission_request_set(
             request,
             EINA_FALSE);
         return;
@@ -1306,37 +1333,16 @@ void ViewLogic::notificationPermissionRequestCallback(
     ViewModule::WebNotification::webNotificationPermissionRequest(
         This->m_window,
         This->m_securityOriginSupport->getSecurityOriginDAO(),
-        This->m_ewkContext,
         eventInfo);
     return;
 }
 
-void ViewLogic::vibrationVibrateCallback(uint64_t time, void* data)
-{
-    LogDebug("vibrationVibrateCallback called");
-    Assert(data);
-    ViewLogic* This = static_cast<ViewLogic*>(data);
-    This->m_vibrationSupport->startVibration(static_cast<long>(time));
-    return;
-}
-
-void ViewLogic::vibrationCancelCallback(void* data)
-{
-    LogDebug("vibrationCancelCallback called");
-    Assert(data);
-    ViewLogic* This = static_cast<ViewLogic*>(data);
-
-    This->m_vibrationSupport->stopVibration();
-
-    return;
-}
-
 // EWK Orientation Callback
 Eina_Bool ViewLogic::orientationLockCallback(
-        Evas_Object* obj,
-        Eina_Bool /*needLock*/,
-        int orientation,
-        void* data)
+    Evas_Object* obj,
+    Eina_Bool /*needLock*/,
+    int orientation,
+    void* data)
 {
     LogDebug("orientationLockCallback called");
     Assert(data);
@@ -1346,15 +1352,15 @@ Eina_Bool ViewLogic::orientationLockCallback(
         LogDebug("orientation is portrait-primary");
         elm_win_rotation_with_resize_set(This->m_window, 0);
         ewk_view_orientation_send(obj, 0);
-    } else if(orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) {
+    } else if (orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) {
         LogDebug("orientation is landscape-primary");
         elm_win_rotation_with_resize_set(This->m_window, 270);
         ewk_view_orientation_send(obj, 90);
-    } else if(orientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) {
+    } else if (orientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) {
         LogDebug("orientation is portrait-secondary");
         elm_win_rotation_with_resize_set(This->m_window, 180);
         ewk_view_orientation_send(obj, 180);
-    } else if(orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) {
+    } else if (orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) {
         LogDebug("orientation is landscape-secondary");
         elm_win_rotation_with_resize_set(This->m_window, 90);
         ewk_view_orientation_send(obj, -90);
@@ -1365,12 +1371,11 @@ Eina_Bool ViewLogic::orientationLockCallback(
     return EINA_TRUE;
 }
 
-
 // Fullscreen API callbacks
 void ViewLogic::enterFullscreenCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* /*eventInfo*/)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* /*eventInfo*/)
 {
     LogInfo("enterFullscreenCallback called");
     Assert(data);
@@ -1380,9 +1385,9 @@ void ViewLogic::enterFullscreenCallback(
     }
 }
 void ViewLogic::exitFullscreenCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* /*eventInfo*/)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* /*eventInfo*/)
 {
     LogInfo("exitFullscreenCallback called");
     Assert(data);
@@ -1393,9 +1398,9 @@ void ViewLogic::exitFullscreenCallback(
 }
 
 void ViewLogic::imeChangedCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogDebug("enter");
     Assert(data);
@@ -1407,9 +1412,9 @@ void ViewLogic::imeChangedCallback(
 }
 
 void ViewLogic::imeOpenedCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* /*eventInfo*/)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* /*eventInfo*/)
 {
     LogDebug("enter");
     Assert(data);
@@ -1421,14 +1426,14 @@ void ViewLogic::imeOpenedCallback(
     args.width = This->m_imeWidth;
     args.height = This->m_imeHeight;
     This->fireJavascriptEvent(
-            static_cast<int>(SoftKeyboardChangeCustomEvent),
-            &args);
+        static_cast<int>(SoftKeyboardChangeCustomEvent),
+        &args);
 }
 
 void ViewLogic::imeClosedCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* /*eventInfo*/)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* /*eventInfo*/)
 {
     LogDebug("enter");
     Assert(data);
@@ -1439,30 +1444,32 @@ void ViewLogic::imeClosedCallback(
     args.state = IME_STATE_OFF;
 
     This->fireJavascriptEvent(
-            static_cast<int>(SoftKeyboardChangeCustomEvent),
-            &args);
+        static_cast<int>(SoftKeyboardChangeCustomEvent),
+        &args);
 }
 
 void ViewLogic::usermediaPermissionRequestCallback(
-        void* data,
-        Evas_Object* /*obj*/,
-        void* eventInfo)
+    void* data,
+    Evas_Object* /*obj*/,
+    void* eventInfo)
 {
     LogDebug("usermediaPermissionRequestCallback called");
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
-    ViewModule::UsermediaSupport::usermediaPermissionRequest(This->m_window,
-                                                             eventInfo);
+    ViewModule::UsermediaSupport::usermediaPermissionRequest(
+        This->m_window,
+        This->m_securityOriginSupport->getSecurityOriginDAO(),
+        eventInfo);
 }
 
-
 // helper method
 CustomHandlerDB::CustomHandlerPtr getCustomHandlerFromData(void* data)
 {
     Assert(data);
     Ewk_Custom_Handlers_Data* handler =
-                static_cast<Ewk_Custom_Handlers_Data*>(data);
-    CustomHandlerDB::CustomHandlerPtr customHandler(new CustomHandlerDB::CustomHandler());
+        static_cast<Ewk_Custom_Handlers_Data*>(data);
+    CustomHandlerDB::CustomHandlerPtr customHandler(
+        new CustomHandlerDB::CustomHandler());
     const char* base_url = ewk_custom_handlers_data_base_url_get(handler);
     if (base_url) {
         LogDebug("base url: " << base_url);
@@ -1544,27 +1551,29 @@ char const * const contentBlackList[contentBlackListLenth] = {
  * @param customHandler
  */
 void saveUserResponse(Wrt::Popup::PopupResponse response,
-        CustomHandlerDB::CustomHandlerPtr customHandler)
+                      CustomHandlerDB::CustomHandlerPtr customHandler)
 {
     switch (response) {
-        case Wrt::Popup::YES_DO_REMEMBER:
-            LogDebug("User allowed, remember");
-            customHandler->user_decision = static_cast<CustomHandlerDB::HandlerState>
-                (CustomHandlerDB::Agreed | CustomHandlerDB::DecisionSaved);
-            break;
-        case Wrt::Popup::YES_DONT_REMEMBER:
-            LogDebug("User allowed, don't remember");
-            customHandler->user_decision = CustomHandlerDB::Agreed;
-            break;
-        case Wrt::Popup::NO_DO_REMEMBER:
-            LogDebug("User didn't allow, remember");
-            customHandler->user_decision = static_cast<CustomHandlerDB::HandlerState>
-                    (CustomHandlerDB::Declined | CustomHandlerDB::DecisionSaved);
-            break;
-        case Wrt::Popup::NO_DONT_REMEMBER:
-            LogDebug("User didn't allow, don't remember");
-            customHandler->user_decision = CustomHandlerDB::Declined;
-            break;
+    case Wrt::Popup::YES_DO_REMEMBER:
+        LogDebug("User allowed, remember");
+        customHandler->user_decision =
+            static_cast<CustomHandlerDB::HandlerState>
+            (CustomHandlerDB::Agreed | CustomHandlerDB::DecisionSaved);
+        break;
+    case Wrt::Popup::YES_DONT_REMEMBER:
+        LogDebug("User allowed, don't remember");
+        customHandler->user_decision = CustomHandlerDB::Agreed;
+        break;
+    case Wrt::Popup::NO_DO_REMEMBER:
+        LogDebug("User didn't allow, remember");
+        customHandler->user_decision =
+            static_cast<CustomHandlerDB::HandlerState>
+            (CustomHandlerDB::Declined | CustomHandlerDB::DecisionSaved);
+        break;
+    case Wrt::Popup::NO_DONT_REMEMBER:
+        LogDebug("User didn't allow, don't remember");
+        customHandler->user_decision = CustomHandlerDB::Declined;
+        break;
     }
 }
 
@@ -1573,13 +1582,13 @@ void saveUserResponse(Wrt::Popup::PopupResponse response,
 //have to be separated
 //TODO attach database only one at the start (not in every callback?)
 void ViewLogic::protocolHandlerRegistrationCallback(void* data,
-                                                    Evas_Object* obj,
+                                                    Evas_Object* /*obj*/,
                                                     void* eventInfo)
 {
     Assert(data);
     LogDebug("enter");
     CustomHandlerDB::CustomHandlerPtr customHandler =
-            getCustomHandlerFromData(eventInfo);
+        getCustomHandlerFromData(eventInfo);
 
     std::string scheme = DPL::ToUTF8String(customHandler->target);
     if (scheme.empty()) {
@@ -1590,8 +1599,7 @@ void ViewLogic::protocolHandlerRegistrationCallback(void* data,
     bool matched = false;
     //scheme on whiteList
     for (int i = 0; i < protocolWhiteListLenth; ++i) {
-        if (0 == strcmp(protocolWhiteList[i], scheme.c_str()))
-        {
+        if (0 == strcmp(protocolWhiteList[i], scheme.c_str())) {
             LogDebug("Match found, protocol can be handled");
             matched = true;
         }
@@ -1605,8 +1613,7 @@ void ViewLogic::protocolHandlerRegistrationCallback(void* data,
         }
         int l = 4;
         char c = scheme[l];
-        while (c != '\0')
-        {
+        while (c != '\0') {
             if (c < 'a' || c > 'z') {
                 LogWarning("Wrong char inside scheme. "
                            << "Only lowercase ASCII letters accepted");
@@ -1622,35 +1629,41 @@ void ViewLogic::protocolHandlerRegistrationCallback(void* data,
     This->attachToCustomHandlersDao();
     CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
     CustomHandlerDB::CustomHandlerPtr handler =
-            handlersDao.getProtocolHandler(customHandler->target,
-                                           customHandler->url,
-                                           customHandler->base_url);
+        handlersDao.getProtocolHandler(customHandler->target,
+                                       customHandler->url,
+                                       customHandler->base_url);
     if (handler && (handler->user_decision & CustomHandlerDB::DecisionSaved)) {
         LogDebug("Protocol already registered - nothing to do");
     } else {
         LogDebug("Protocol handler not found");
         Wrt::Popup::PopupResponse response =
-            GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::YES_DO_REMEMBER :
-                Wrt::Popup::PopupInvoker().askYesNoCheckbox(
-                        PROTOCOL_HANDLER_ASK_TITLE,
-                        PROTOCOL_HANDLER_ASK_MSG,
-                        PROTOCOL_HANDLER_ASK_REMEMBER);
+            GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::
+                YES_DO_REMEMBER :
+            Wrt::Popup::PopupInvoker().askYesNoCheckbox(
+                PROTOCOL_HANDLER_ASK_TITLE,
+                PROTOCOL_HANDLER_ASK_MSG,
+                PROTOCOL_HANDLER_ASK_REMEMBER);
         saveUserResponse(response, customHandler);
-        if (customHandler->user_decision == CustomHandlerDB::Declined)
+        if (customHandler->user_decision == CustomHandlerDB::Declined) {
             return;
-        handlersDao.registerProtocolHandler(*(customHandler.get()));
+        }
         if (customHandler->user_decision & CustomHandlerDB::Agreed) {
             //TODO remove old default handler somehow from appsvc
             LogDebug("Registering appservice entry");
             int ret = appsvc_set_defapp(APPSVC_OPERATION_VIEW,
-                    NULL,
-                    DPL::ToUTF8String(customHandler->target).c_str(),
-                    DPL::ToUTF8String(This->m_model->TizenId).c_str());
-            if (APPSVC_RET_OK != ret)
-            {
+                                        NULL,
+                                        DPL::ToUTF8String(
+                                            customHandler->target).c_str(),
+                                        DPL::ToUTF8String(This->m_model->
+                                                              TizenId).c_str());
+            if (APPSVC_RET_OK != ret) {
                 LogWarning("Appsvc entry failed: " << ret);
+                //no database change
+                return;
             }
         }
+        handlersDao.registerProtocolHandler(*(customHandler.get()));
+
         LogDebug("Protocal saved");
     }
 
@@ -1658,42 +1671,45 @@ void ViewLogic::protocolHandlerRegistrationCallback(void* data,
 }
 
 void ViewLogic::protocolHandlerIsRegisteredCallback(void* data,
-                                                    Evas_Object* obj,
+                                                    Evas_Object* /*obj*/,
                                                     void* eventInfo)
 {
     LogDebug("enter");
-    CustomHandlerDB::CustomHandlerPtr customHandler = getCustomHandlerFromData(eventInfo);
+    CustomHandlerDB::CustomHandlerPtr customHandler = getCustomHandlerFromData(
+            eventInfo);
     ViewLogic* This = static_cast<ViewLogic*>(data);
     LogDebug("Creating handlers dao");
     This->attachToCustomHandlersDao();
     CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
-        CustomHandlerDB::CustomHandlerPtr handler =
-            handlersDao.getProtocolHandler(customHandler->target,
-                                           customHandler->url,
-                                           customHandler->base_url);
+    CustomHandlerDB::CustomHandlerPtr handler =
+        handlersDao.getProtocolHandler(customHandler->target,
+                                       customHandler->url,
+                                       customHandler->base_url);
     if (handler) {
-        if (handler->user_decision & CustomHandlerDB::Agreed)
+        if (handler->user_decision & CustomHandlerDB::Agreed) {
             ewk_custom_handlers_data_result_set(
-                static_cast<Ewk_Custom_Handlers_Data*>(data),
+                static_cast<Ewk_Custom_Handlers_Data*>(eventInfo),
                 EWK_CUSTOM_HANDLERS_REGISTERED);
-        else
+        } else {
             ewk_custom_handlers_data_result_set(
-                static_cast<Ewk_Custom_Handlers_Data*>(data),
+                static_cast<Ewk_Custom_Handlers_Data*>(eventInfo),
                 EWK_CUSTOM_HANDLERS_DECLINED);
-    } else
-            ewk_custom_handlers_data_result_set(
-                static_cast<Ewk_Custom_Handlers_Data*>(data),
-                EWK_CUSTOM_HANDLERS_NEW);
+        }
+    } else {
+        ewk_custom_handlers_data_result_set(
+            static_cast<Ewk_Custom_Handlers_Data*>(eventInfo),
+            EWK_CUSTOM_HANDLERS_NEW);
+    }
     This->detachFromCustomHandlersDao();
 }
 
 void ViewLogic::protocolHandlerUnregistrationCallback(void* data,
-                                                      Evas_Object* obj,
+                                                      Evas_Object* /*obj*/,
                                                       void* eventInfo)
 {
     LogDebug("enter");
     CustomHandlerDB::CustomHandlerPtr customHandler =
-            getCustomHandlerFromData(eventInfo);
+        getCustomHandlerFromData(eventInfo);
     ViewLogic* This = static_cast<ViewLogic*>(data);
     LogDebug("Creating handlers dao");
     This->attachToCustomHandlersDao();
@@ -1702,37 +1718,41 @@ void ViewLogic::protocolHandlerUnregistrationCallback(void* data,
         handlersDao.getProtocolHandler(customHandler->target,
                                        customHandler->url,
                                        customHandler->base_url);
+    This->detachFromCustomHandlersDao();
     if (handlerCheck) {
-        if (handlerCheck->user_decision & CustomHandlerDB::Agreed)
-            appsvc_unset_defapp(DPL::ToUTF8String(This->m_model->TizenId).c_str());
-
+        if (handlerCheck->user_decision & CustomHandlerDB::Agreed) {
+            int ret = appsvc_unset_defapp(
+                    DPL::ToUTF8String(This->m_model->TizenId).c_str());
+            if (APPSVC_RET_OK != ret) {
+                LogWarning("Failed to unregister appsvc entry");
+                return;
+            }
+        }
+        //if appsvc ok change custom_handlers_db
         handlersDao.unregisterProtocolHandler(customHandler->target,
                                               customHandler->url,
                                               customHandler->base_url);
-    } else
+    } else {
         LogDebug("Nothing to unregister");
-
-    This->detachFromCustomHandlersDao();
+    }
 }
 
 void ViewLogic::contentHandlerRegistrationCallback(void* data,
-                                                   Evas_Object* obj,
+                                                   Evas_Object* /*obj*/,
                                                    void* eventInfo)
 {
     Assert(data);
     LogDebug("enter");
     CustomHandlerDB::CustomHandlerPtr customHandler =
-            getCustomHandlerFromData(eventInfo);
+        getCustomHandlerFromData(eventInfo);
 
     std::string mimeType = DPL::ToUTF8String(customHandler->target);
     if (mimeType.empty()) {
         LogError("No mimeType provided.");
         return;
     }
-    for (int i = 0; i < contentBlackListLenth; ++i)
-    {
-        if (0 == strcmp(contentBlackList[i], mimeType.c_str()))
-        {
+    for (int i = 0; i < contentBlackListLenth; ++i) {
+        if (0 == strcmp(contentBlackList[i], mimeType.c_str())) {
             LogWarning("mimeType blacklisted");
             //throw SecurityException
             return;
@@ -1743,43 +1763,47 @@ void ViewLogic::contentHandlerRegistrationCallback(void* data,
     LogDebug("Creating handlers dao");
     This->attachToCustomHandlersDao();
     CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
-        CustomHandlerDB::CustomHandlerPtr handler =
-            handlersDao.getContentHandler(customHandler->target,
-                                          customHandler->url,
-                                          customHandler->base_url);
+    CustomHandlerDB::CustomHandlerPtr handler =
+        handlersDao.getContentHandler(customHandler->target,
+                                      customHandler->url,
+                                      customHandler->base_url);
     if (handler && (handler->user_decision & CustomHandlerDB::DecisionSaved)) {
         LogDebug("Protocol already registered - nothing to do");
     } else {
         LogDebug("Protocol handler not found");
         Wrt::Popup::PopupResponse response =
-            GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::YES_DO_REMEMBER :
-                Wrt::Popup::PopupInvoker().askYesNoCheckbox(
-                        CONTENT_HANDLER_ASK_TITLE,
-                        CONTENT_HANDLER_ASK_MSG,
-                        CONTENT_HANDLER_AKS_REMEMBER);
+            GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::
+                YES_DO_REMEMBER :
+            Wrt::Popup::PopupInvoker().askYesNoCheckbox(
+                CONTENT_HANDLER_ASK_TITLE,
+                CONTENT_HANDLER_ASK_MSG,
+                CONTENT_HANDLER_AKS_REMEMBER);
         saveUserResponse(response, customHandler);
-        if (customHandler->user_decision == CustomHandlerDB::Declined)
+        if (customHandler->user_decision == CustomHandlerDB::Declined) {
             return;
-        handlersDao.registerContentHandler(*(customHandler.get()));
+        }
         if (customHandler->user_decision & CustomHandlerDB::Agreed) {
             //TODO remove old default handler somehow from appsvc
             LogDebug("Registering appservice entry");
             int ret = appsvc_set_defapp(APPSVC_OPERATION_VIEW,
-                    DPL::ToUTF8String(customHandler->target).c_str(),
-                    NULL,
-                    DPL::ToUTF8String(This->m_model->TizenId).c_str());
-            if (APPSVC_RET_OK != ret)
-            {
+                                        DPL::ToUTF8String(
+                                            customHandler->target).c_str(),
+                                        NULL,
+                                        DPL::ToUTF8String(This->m_model->
+                                                              TizenId).c_str());
+            if (APPSVC_RET_OK != ret) {
                 LogWarning("Appsvc entry failed: " << ret);
+                return;
             }
         }
+        handlersDao.registerContentHandler(*(customHandler.get()));
         LogDebug("Content saved");
     }
     This->detachFromCustomHandlersDao();
 }
 
 void ViewLogic::contentHandlerIsRegisteredCallback(void* data,
-                                                   Evas_Object* obj,
+                                                   Evas_Object* /*obj*/,
                                                    void* eventInfo)
 {
     LogDebug("enter");
@@ -1790,57 +1814,65 @@ void ViewLogic::contentHandlerIsRegisteredCallback(void* data,
 
     This->attachToCustomHandlersDao();
     CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
-        CustomHandlerDB::CustomHandlerPtr handler =
-            handlersDao.getContentHandler(customHandler->target,
-                                          customHandler->url,
-                                          customHandler->base_url);
+    CustomHandlerDB::CustomHandlerPtr handler =
+        handlersDao.getContentHandler(customHandler->target,
+                                      customHandler->url,
+                                      customHandler->base_url);
     if (handler) {
-        if (handler->user_decision & CustomHandlerDB::Agreed)
+        if (handler->user_decision & CustomHandlerDB::Agreed) {
             ewk_custom_handlers_data_result_set(
-                static_cast<Ewk_Custom_Handlers_Data*>(data),
+                static_cast<Ewk_Custom_Handlers_Data*>(eventInfo),
                 EWK_CUSTOM_HANDLERS_REGISTERED);
-        else
+        } else {
             ewk_custom_handlers_data_result_set(
-                static_cast<Ewk_Custom_Handlers_Data*>(data),
+                static_cast<Ewk_Custom_Handlers_Data*>(eventInfo),
                 EWK_CUSTOM_HANDLERS_DECLINED);
-    } else
-            ewk_custom_handlers_data_result_set(
-                static_cast<Ewk_Custom_Handlers_Data*>(data),
-                EWK_CUSTOM_HANDLERS_NEW);
+        }
+    } else {
+        ewk_custom_handlers_data_result_set(
+            static_cast<Ewk_Custom_Handlers_Data*>(eventInfo),
+            EWK_CUSTOM_HANDLERS_NEW);
+    }
     This->detachFromCustomHandlersDao();
 }
 
 void ViewLogic::contentHandlerUnregistrationCallback(void* data,
-                                                     Evas_Object* obj,
+                                                     Evas_Object* /*obj*/,
                                                      void* eventInfo)
 {
     LogDebug("enter");
     CustomHandlerDB::CustomHandlerPtr customHandler =
-            getCustomHandlerFromData(eventInfo);
+        getCustomHandlerFromData(eventInfo);
     ViewLogic* This = static_cast<ViewLogic*>(data);
     LogDebug("Creating handlers dao");
     This->attachToCustomHandlersDao();
     CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
-        CustomHandlerDB::CustomHandlerPtr handlerCheck =
-            handlersDao.getContentHandler(customHandler->target,
-                                           customHandler->url,
-                                           customHandler->base_url);
-        if (handlerCheck) {
-            if (handlerCheck->user_decision & CustomHandlerDB::Agreed)
-                appsvc_unset_defapp(DPL::ToUTF8String(This->m_model->TizenId).c_str());
-
-            handlersDao.unregisterContentHandler(customHandler->target,
-                                                     customHandler->url,
-                                                     customHandler->base_url);
-        } else
-            LogDebug("Nothing to unregister");
+    CustomHandlerDB::CustomHandlerPtr handlerCheck =
+        handlersDao.getContentHandler(customHandler->target,
+                                      customHandler->url,
+                                      customHandler->base_url);
     This->detachFromCustomHandlersDao();
+    if (handlerCheck) {
+        if (handlerCheck->user_decision & CustomHandlerDB::Agreed) {
+            int ret = appsvc_unset_defapp(
+                    DPL::ToUTF8String(This->m_model->TizenId).c_str());
+            if (APPSVC_RET_OK != ret) {
+                LogWarning("Failed to unregister mime handler from appsvc");
+                return;
+            }
+        }
+        handlersDao.unregisterContentHandler(customHandler->target,
+                                             customHandler->url,
+                                             customHandler->base_url);
+    } else {
+        LogDebug("Nothing to unregister");
+    }
 }
 
 void ViewLogic::didRunJavaScriptCallback(
-        Evas_Object* /*obj*/,
-        const char* result,
-        void* /*userData*/)
+    Evas_Object* /*obj*/,
+    const char* result,
+    void* /*userData*/)
 {
     LogInfo("didRunJavaScriptCallback called");
     LogInfo("result = " << result);
@@ -1854,204 +1886,80 @@ Eina_Bool ViewLogic::windowCloseIdlerCallback(void* data)
     return ECORE_CALLBACK_CANCEL;
 }
 
-int ViewLogic::appcoreLowMemoryCallback(void *data)
-{
-    LogInfo("appcoreLowMemoryCallback");
-    Assert(data);
-    ViewLogic* This = static_cast<ViewLogic*>(data);
-
-    if (NULL == This->m_ewkContext) {
-        LogInfo("ewk isn't initialize at this moment");
-    } else {
-        // Crash may occur on specific situation
-        // So use the followings after they become stable
-        //ewk_context_cache_clear(This->m_ewkContext);
-        //ewk_context_notify_low_memory(This->m_ewkContext);
-    }
-
-    return 0;
-}
-
-void ViewLogic::databaseUsagePermissionRequestCallback(
+void ViewLogic::certificateConfirmRequestCallback(
     void* data,
     Evas_Object* /*obj*/,
     void* eventInfo)
 {
-    LogDebug("databaseUsagePermissionRequestCallback called");
-    Assert(data);
-    ViewLogic* This = static_cast<ViewLogic*>(data);
-    Assert(eventInfo);
-
-    if (This->m_securityOriginSupport->isNeedPermissionCheck(
-        SecurityOriginDB::FEATURE_WEB_DATABASE)
-        == WrtDB::SETTINGS_TYPE_OFF)
-    {
-        // default value is deny
-        return;
-    }
-    ViewModule::WebStorageSupport::webStorageCreatePermissionRequest(
-        This->m_window,
-        This->m_securityOriginSupport->getSecurityOriginDAO(),
-        eventInfo);
-    return;
- }
+    LogDebug("certificateConfirmRequestCallback called");
 
-void ViewLogic::fileSystemPermissionRequestCallback(
-    void* data,
-    Evas_Object* /*obj*/,
-    void* eventInfo)
-{
-    LogDebug("fileSystemPermissionRequestCallback called");
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
-
-    if (This->m_securityOriginSupport->isNeedPermissionCheck(
-        SecurityOriginDB::FEATURE_FILE_SYSTEM_ACCESS)
-        == WrtDB::SETTINGS_TYPE_OFF)
-    {
-        Ewk_Context_File_System_Permission* fileSystemPermission =
-             static_cast<Ewk_Context_File_System_Permission*>(eventInfo);
-        ewk_context_file_system_permission_allow_set(fileSystemPermission,
-                                                     EINA_FALSE);
-        return;
-    }
-
     Assert(eventInfo);
-    ViewModule::FileSystemSupport::fileSystemPermissionRequest(
+    ViewModule::CertificateConfirmSupport::certificatePermissionRequest(
         This->m_window,
-        This->m_securityOriginSupport->getSecurityOriginDAO(),
+        This->m_certificateSupport->getCertificateDAO(),
         eventInfo);
 }
 
-void ViewLogic::certificateConfirmRequestCallback(
+void ViewLogic::authenticationChallengeRequestCallback(
     void* data,
     Evas_Object* /*obj*/,
     void* eventInfo)
 {
-    LogDebug("certificateConfirmRequestCallback called");
+    LogDebug("authenticationChallengeRequestCallback called");
 
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
-    Assert(eventInfo);
-        Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
-        static_cast<Ewk_Certificate_Policy_Decision*>(eventInfo);
-
-    bool status = This->askUserForCertificateConfirm();
-    if(!status) {
-        ewk_certificate_policy_decision_allowed_set(
-            certificatePolicyDecision,
-            EINA_FALSE);
-    }
-    else {
-        ewk_certificate_policy_decision_allowed_set(
-            certificatePolicyDecision,
-            EINA_TRUE);
+    const char* url = ewk_view_url_get(This->m_currentEwkView);
+    if (!url || strlen(url) == 0) {
+        url = This->m_currentUri.c_str();
     }
+    Assert(eventInfo);
+    ViewModule::AuthenticationChallengeSupport::authenticationChallengeRequest(
+        This->m_currentEwkView,
+        url,
+        eventInfo);
 }
 
-bool ViewLogic::askUserForCertificateConfirm()
-{
-    return Wrt::Popup::PopupInvoker().askYesNo(
-        CERTIFICATE_CONFIRM_REQUEST_ASK_TITLE,
-        CERTIFICATE_CONFIRM_REQUEST_ASK_BODY);
-}
-
-void ViewLogic::didRecieveMessageFromInjectedBundle(
-        const char* name,
-        const char* /*body*/)
-{
-    LogDebug("did recive message " << name);
-}
-
-void ViewLogic::didReceiveSynchronousMessage(
-        const char* name,
-        const char* body,
-        char** returnData)
+std::string ViewLogic::requestUrlBlocked(const std::string& blockedUrl)
 {
-    LogDebug("didReceiveSynchronousMessage called");
-    Assert(name);
-    Assert(returnData);
+    LogInfo("enter");
 
-    if (!body) {
-        LogDebug("body is empty");
-        *returnData = NULL;
-        return;
+    if (m_model->Type.Get().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
+        // block this page and open it in browser
+        LogDebug("Request was blocked by WARP: " << blockedUrl);
+        LogDebug("open browser : " << blockedUrl);
+        bundle* bundleData = bundle_create();
+        appsvc_set_operation(bundleData, APPSVC_OPERATION_VIEW);
+        appsvc_set_uri(bundleData, blockedUrl.c_str());
+        CONTROLLER_POST_EVENT(
+            ApplicationLauncher,
+            ApplicationLauncherEvents::LaunchApplicationByAppService(
+                bundleData,
+                NULL,
+                NULL));
     }
-    if (!strcmp(name, uriBlockedMessageName)) {
-        LogDebug("received : " << uriBlockedMessageName);
-        // Currently WebProcess informs obly about blocked
-        // URI - URI localization and security chekcs are
-        // done by WebProcess itself (see: wrt-wk2-bundle.cpp
-        // and bundle_uri_handling.cpp)
-        rememberBlockedURI(DPL::FromUTF8String(body));
-        *returnData = NULL;
-    } else if (!strcmp(name, uriChangedMessageName)) {
-        LogDebug("received : " << uriChangedMessageName);
-        std::string ret = requestUriChanged(DPL::FromUTF8String(body));
-        *returnData =  strdup(ret.c_str());
-    }
-}
 
-void ViewLogic::rememberBlockedURI(const DPL::String& inputURI)
-{
-    m_blockedUri = DPL::ToUTF8String(inputURI);
-    LogInfo("set blocked uri to open browser later : " << m_blockedUri);
-    return;
+    // set block url. This is used on load finished callback
+    m_blockedUri = blockedUrl;
+
+    // This is used in case of returning previous page
+    return URICHANGE_PLUGIN_NO_CHANGE;
 }
 
-std::string ViewLogic::requestUriChanged(const DPL::String& changedURL)
+std::string ViewLogic::requestUrlChanged(const std::string& changedUrl)
 {
     using namespace ViewModule::SecuritySupport;
 
-    std::string url = DPL::ToUTF8String(changedURL);
-    LogInfo("URL = [" << url << "]");
-
-    // check WARP
-    // If url is same to URICHANGE_BLOCKED_URL,
-    // this url has been already blocked by willsend.
-    // So current page should be moved to previous page
-    if (url == URICHANGE_BLOCKED_URL)
-    {
-        if (m_model->Type.Get().appType == WrtDB::APP_TYPE_TIZENWEBAPP)
-        {
-            // block this page and open it in browser
-            LogDebug("Request was blocked by WARP: " << url.c_str());
-            if (!m_blockedUri.empty()) {
-                LogDebug("open browser : " << m_blockedUri);
-                bundle* bundleData = bundle_create();
-                appsvc_set_operation(bundleData, APPSVC_OPERATION_VIEW);
-                appsvc_set_uri(bundleData, m_blockedUri.c_str());
-                CONTROLLER_POST_EVENT(
-                    ApplicationLauncher,
-                    ApplicationLauncherEvents::LaunchApplicationByAppService(
-                        bundleData,
-                        NULL,
-                        NULL));
-                m_blockedUri = std::string();
-            }
-        }
-        if (ewk_view_back_possible(m_currentEwkView)) {
-            // go back to previous page
-            ewk_view_back(m_currentEwkView);
-        } else {
-            // stop current page
-            ewk_view_stop(m_currentEwkView);
-            ecore_idler_add(windowCloseIdlerCallback, this);
-        }
-
-        // This is used in case of returning previous page
-        m_currentUri = url;
-        return URICHANGE_PLUGIN_NO_CHANGE;
-    }
-
-    m_currentUri = url;
+    LogInfo("changed url: " << changedUrl);
 
     // Check if this url with 'http' or 'https' is included in whitelist,
     // which has lists of accessible external documents and
     // used for ONLY Tizen app
     std::string matchedScheme;
     std::string matchedUri;
-    pcrecpp::RE(PATTERN_URI_CHANGE).PartialMatch(url.c_str(),
+    pcrecpp::RE(PATTERN_URI_CHANGE).PartialMatch(changedUrl.c_str(),
                                                  &matchedUri,
                                                  &matchedScheme);
     ViewModule::Scheme scheme(matchedScheme);
@@ -2059,7 +1967,7 @@ std::string ViewLogic::requestUriChanged(const DPL::String& changedURL)
         scheme.GetType() == ViewModule::Scheme::HTTPS)
     {
         if (m_model->Type.Get().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
-            if (!checkWhitelist(url.c_str())) {
+            if (!checkWhitelist(changedUrl.c_str())) {
                 LogInfo("This uri is not included in white document list");
                 return URICHANGE_PLUGIN_STOP_ONLY;
             }
@@ -2071,8 +1979,7 @@ std::string ViewLogic::requestUriChanged(const DPL::String& changedURL)
         }
     }
 
-    // register javascript object for plugins to be used
-    LogInfo("Register Plugin Objects");
+    m_currentUri = changedUrl;
     return URICHANGE_PLUGIN_RESTART;
 }
 
@@ -2106,8 +2013,9 @@ void ViewLogic::windowClose()
 
         // resume ewkView
         /* In case we support many pages in parallel
-           then view is not suspended*/
+         * then view is not suspended*/
         //resumeEwkView(m_currentEwkView);
+        setEwkViewVisible(m_currentEwkView);
 
         // show ewkView
         if (!m_cbs->bufferSet.empty()) {
index 709a410..6fb03ac 100755 (executable)
@@ -39,6 +39,7 @@
 class SchemeSupport;
 namespace ViewModule {
 class SecurityOriginSupport;
+class CertificateSupport;
 }
 
 class ViewLogic : public ViewModule::IViewModule
@@ -47,15 +48,13 @@ class ViewLogic : public ViewModule::IViewModule
     ViewLogic();
     virtual ~ViewLogic();
 
+    // IViewModule Impl
     bool createWebView(Ewk_Context* context,
                        Evas_Object* window);
     void destroyWebView();
-    void initialize();
-    void terminate();
     void prepareView(WidgetModel* m, const std::string &startUrl);
     void showWidget();
     void hideWidget();
-    void changeViewVisibility(bool isVisible);
     void suspendWidget();
     void resumeWidget();
     void resetWidget();
@@ -64,10 +63,13 @@ class ViewLogic : public ViewModule::IViewModule
     Evas_Object* getCurrentWebview();
     void fireJavascriptEvent(int event, void* data);
     void setUserCallbacks(const WRT::UserDelegatesPtr& cbs);
+    void checkSyncMessageFromBundle(
+            const char* name,
+            const char* body,
+            char** returnData);
+    void downloadData(const char* url);
+    void activateVibration(bool on, uint64_t time);
 
-    // Ewk_Context operations
-    void initializeEwkContext(Ewk_Context* context);
-    void finalizeEwkContext();
 
   private:
     void initializeSupport();
@@ -82,213 +84,182 @@ class ViewLogic : public ViewModule::IViewModule
     void removeEwkView(Evas_Object *wkView);
     void resumeEwkView(Evas_Object *wkView);
     void suspendEwkView(Evas_Object *wkView);
+    void setEwkViewVisible(Evas_Object *wkView);
+    void setEwkViewInvisible(Evas_Object *wkView);
     void resumeWebkit(Evas_Object *wkView);
     void suspendWebkit(Evas_Object *wkView);
 
-    // message from injected bundle Callback
-    static void contextMessageFromInjectedBundleCallback(
-            const char* name,
-            const char* body,
-            char** returnData,
-            void* userData);
-
-    // EWK Context Callback
-    static void didStartDownloadCallback(
-            const char* downloadUrl,
-            void* data);
-
     // WKPageLoaderClient
     static void loadStartedCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void loadFinishedCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void titleChangedCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void loadProgressCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void loadProgressFinishedCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void processCrashedCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
 
     // EWK Callback
     static void createWindowCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void closeWindowCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
 
     // EWK PolicyDecide Callback
     static void policyNavigationDecideCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void policyNewWindowDecideCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void pageResponseDecideCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
 
     // EWK ContextMenu Callback
     static void contextmenuCustomizeCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
 
     // EWK FormClient Callback
     static void formSubmitCallback(
-            void *data,
-            Evas_Object *obj,
-            void *eventInfo);
+        void *data,
+        Evas_Object *obj,
+        void *eventInfo);
 
     // EWK Geolocation Callback
     static void geolocationPermissionRequestCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
 
     // EWK Notification Callback
     static void notificationShowCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void notificationCancelCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void notificationPermissionRequestCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
-
-    // EWK Vibration Callback
-    static void vibrationVibrateCallback(uint64_t time, void* data);
-    static void vibrationCancelCallback(void* data);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
 
     // EWK Orientation Callback
     static Eina_Bool orientationLockCallback(
-            Evas_Object* obj,
-            Eina_Bool needLock,
-            int orientation,
-            void* data);
+        Evas_Object* obj,
+        Eina_Bool needLock,
+        int orientation,
+        void* data);
 
     // EWK Fullscreen API callbacks
     static void enterFullscreenCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void exitFullscreenCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
 
     // EWK IME Change/Show/Hide Callback
     static void imeChangedCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void imeOpenedCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
     static void imeClosedCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
 
     // EWK Usermedia Callback
     static void usermediaPermissionRequestCallback(
-            void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+        void* data,
+        Evas_Object* obj,
+        void* eventInfo);
 
     // custom content/scheme handlers
     static void protocolHandlerRegistrationCallback(void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+                                                    Evas_Object* obj,
+                                                    void* eventInfo);
     static void protocolHandlerIsRegisteredCallback(void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+                                                    Evas_Object* obj,
+                                                    void* eventInfo);
     static void protocolHandlerUnregistrationCallback(void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+                                                      Evas_Object* obj,
+                                                      void* eventInfo);
 
     static void contentHandlerRegistrationCallback(void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+                                                   Evas_Object* obj,
+                                                   void* eventInfo);
     static void contentHandlerIsRegisteredCallback(void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+                                                   Evas_Object* obj,
+                                                   void* eventInfo);
     static void contentHandlerUnregistrationCallback(void* data,
-            Evas_Object* obj,
-            void* eventInfo);
+                                                     Evas_Object* obj,
+                                                     void* eventInfo);
 
-    // database usage permission request callback
-    static void databaseUsagePermissionRequestCallback(
-        void* data,
-        Evas_Object* obj,
-        void* eventInfo);
-    // file System Permission Request Callback
-    static void fileSystemPermissionRequestCallback(
+    static void certificateConfirmRequestCallback(
         void* data,
         Evas_Object* obj,
         void* eventInfo);
-    static void certificateConfirmRequestCallback(
+    bool askUserForCertificateConfirm();
+    static void authenticationChallengeRequestCallback(
         void* data,
         Evas_Object* obj,
         void* eventInfo);
-    bool askUserForCertificateConfirm();
 
     void attachToCustomHandlersDao();
     void detachFromCustomHandlersDao();
 
     // JS execute callback
     static void didRunJavaScriptCallback(
-            Evas_Object* obj,
-            const char* result,
-            void* userData);
+        Evas_Object* obj,
+        const char* result,
+        void* userData);
 
     // idler callback
     static Eina_Bool windowCloseIdlerCallback(void *data);
 
-    // appcore event callback
-    static int appcoreLowMemoryCallback(void *data);
-
-    //bundle
-    void didRecieveMessageFromInjectedBundle(
-            const char* name,
-            const char* body);
-    void didReceiveSynchronousMessage(
-            const char* name,
-            const char* body,
-            char** returnData);
-
     // security
-    void rememberBlockedURI(const DPL::String& str);
-    std::string requestUriChanged(const DPL::String& changedURL);
+    std::string requestUrlBlocked(const std::string& blockedUrl);
+    std::string requestUrlChanged(const std::string& changedUrl);
 
     // window
     void windowClose(void);
 
     Ewk_Context* m_ewkContext;
+    bool m_attachedToCustomHandlerDao;
     std::list<Evas_Object*> m_ewkViewList;
     Evas_Object* m_currentEwkView;
     Evas_Object* m_closedEwkView;
@@ -296,19 +267,21 @@ class ViewLogic : public ViewModule::IViewModule
     WidgetModel* m_model;
     std::string m_currentUri;
     std::string m_blockedUri;
+    std::string m_currentTitle;
     std::string m_theme;
     std::string m_startUrl;
     WRT::UserDelegatesPtr m_cbs;
     size_t m_imeWidth;
     size_t m_imeHeight;
     bool m_isBackgroundReload;
+    bool m_isBackgroundSupport;
 
     std::unique_ptr<SchemeSupport> m_schemeSupport;
     std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
     std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
     std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
-    bool m_attachedToCustomHandlerDao;
-
+    std::unique_ptr<ViewModule::CertificateSupport> m_certificateSupport;
+    
     static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
 };
 
diff --git a/src/view/webkit/view_logic_authentication_challenge_support.cpp b/src/view/webkit/view_logic_authentication_challenge_support.cpp
new file mode 100644 (file)
index 0000000..85ce0d5
--- /dev/null
@@ -0,0 +1,341 @@
+/*
+ * 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    view_logic_authentication_challenge_support.cpp
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ */
+
+#include "view_logic_authentication_challenge_support.h"
+
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <Elementary.h>
+#include <EWebKit2.h>
+
+namespace ViewModule {
+namespace {
+
+const char* const EVAS_SMART_CALLBACK_CLICKED = "clicked";
+const char* const EVAS_SMART_CALLBACK_CHANGED = "changed";
+const char* const EVAS_SMART_CALLBACK_PREEDIT_CHANGED = "preedit,changed";
+const char* const EVAS_SMART_CALLBACK_FOCUSED = "focused";
+const char* const EVAS_SMART_CALLBACK_UNFOCUSED = "unfocused";
+const char* const ELM_SIGNAL_ERASER_CLICKED = "elm,eraser,clicked";
+const char* const ELM_SIGNAL_STATE_GUIDETEXT_HIDE = "elm,state,guidetext,hide";
+const char* const ELM_SIGNAL_STATE_ERASER_SHOW = "elm,state,eraser,show";
+const char* const ELM_SIGNAL_STATE_HIDE_SHOW = "elm,state,eraser,hide";
+const char* const ELM_SWALLOW_CONTENT = "elm.swallow.content";
+const char* const ELM_SWALLOW_LABEL = "elm.swallow.label";
+const char* const ELM_SWALLOW_IDFIELD = "elm.swallow.idfield";
+const char* const ELM_SWALLOW_PASSWDFIELD = "elm.swallow.passwdfield";
+
+const char* const DAEMON_EDJ_PATH = "/usr/share/edje/wrt/Daemon.edj";
+const char* const GROUP_NAME_AUTHENTICATION_CHALLENGE_POPUP =
+    "authChallengePopup";
+const char* const THEME_EDITFIELD = "editfield";
+const char* const THEME_DEFAULT = "default";
+
+const char* const STYLE_POPUP_BUTTON_DEFAULT = "popup_button/default";
+const char* const STYLE_DEFAULT_EDITFIELD =
+    "DEFAULT='font_size=34 color=#808080 ellipsis=1'";
+
+const char* const PART_IDFIELD_TEXT = "idfield_text";
+const char* const PART_PASSWORDFIELD_TEXT = "passwdfield_text";
+const char* const PART_BUTTON1 = "button1";
+const char* const PART_BUTTON2 = "button2";
+
+const char* const ELM = "elm";
+const char* const TITLE_TEXT = "title,text";
+const char* const LAYOUT = "layout";
+const char* const ERASER = "eraser";
+const char* const WIDGET_NAME_POPUP = "elm_popup";
+const char* const WIDGET_NAME_NAVIFRAME = "elm_naviframe";
+
+const char* const AUTHENTICATION_CHALLENGE_TITLE_TEXT =
+    "Authentication Requested";
+const char* const AUTHENTICATION_CHALLENGE_BODY_PRETEXT =
+    "A username and password are being requested by ";
+const char* const AUTHENTICATION_CHALLENGE_BODY_MIDDLETEXT =
+    ". The site says: ";
+
+const char* const TEXT_DOUBLE_QUOTATION_MARKS = " \"";
+const char* const TEXT_ID_FIELD = " User Name: ";
+const char* const TEXT_PASSWORD_FIELD = " Password: ";
+const char* const TEXT_OK = "Ok";
+const char* const TEXT_CANCEL = "Cancel";
+
+struct authenticationData {
+    Ewk_Auth_Challenge* m_authChallenge;
+    std::string m_bodyText;
+    Evas_Object* m_navi;
+    Evas_Object* m_idLayout;
+    Evas_Object* m_passLayout;
+};
+
+// function declare
+void askUserInformation(authenticationData* authData);
+Evas_Object* createEditLayout(Evas_Object* parent, bool isPasswordEdit = false);
+
+// edit callback
+static void editChangedCallback(void* data, Evas_Object* obj, void* eventInfo);
+static void editFocusedCallback(void* data, Evas_Object* obj, void* eventInfo);
+static void editUnfocusedCallback(void* data,
+                                  Evas_Object* obj,
+                                  void* eventInfo);
+static void eraserClickedCallback(void* data,
+                                  Evas_Object* obj,
+                                  const char* emission,
+                                  const char* source);
+
+// button callback
+Evas_Object* getEvasObjectByWidgetName(Evas_Object* obj, const char* name);
+void buttonCallback(void* data, Evas_Object* obj, void* eventInfo);
+
+void askUserInformation(authenticationData* authData)
+{
+    Assert(authData);
+    Evas_Object* popup = elm_popup_add(authData->m_navi);
+    evas_object_size_hint_weight_set(popup,
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
+    evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    elm_object_part_text_set(popup,
+                             TITLE_TEXT,
+                             AUTHENTICATION_CHALLENGE_TITLE_TEXT);
+
+    Evas_Object* label = elm_label_add(popup);
+    evas_object_size_hint_weight_set(label,
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
+    elm_label_line_wrap_set(label , ELM_WRAP_WORD);
+    elm_object_text_set(label, authData->m_bodyText.c_str());
+
+    authData->m_idLayout = createEditLayout(popup);
+    authData->m_passLayout = createEditLayout(popup, true);
+
+    Evas_Object* popupLayout = elm_layout_add(popup);
+    elm_layout_file_set(popupLayout,
+                        DAEMON_EDJ_PATH,
+                        GROUP_NAME_AUTHENTICATION_CHALLENGE_POPUP);
+    evas_object_size_hint_weight_set(popupLayout,
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
+    /* FIXME : The text should be translated. */
+    edje_object_part_text_set(elm_layout_edje_get(popupLayout),
+                              PART_IDFIELD_TEXT,
+                              TEXT_ID_FIELD);
+    edje_object_part_text_set(elm_layout_edje_get(popupLayout),
+                              PART_PASSWORDFIELD_TEXT,
+                              TEXT_PASSWORD_FIELD);
+
+    elm_object_part_content_set(popupLayout, ELM_SWALLOW_LABEL, label);
+    elm_object_part_content_set(popupLayout,
+                                ELM_SWALLOW_IDFIELD,
+                                authData->m_idLayout);
+    elm_object_part_content_set(popupLayout,
+                                ELM_SWALLOW_PASSWDFIELD,
+                                authData->m_passLayout);
+    elm_object_content_set(popup, popupLayout);
+
+    Evas_Object* lButton = elm_button_add(popup);
+    elm_object_text_set(lButton, TEXT_OK);
+    elm_object_style_set(lButton, STYLE_POPUP_BUTTON_DEFAULT);
+    elm_object_part_content_set(popup, PART_BUTTON1, lButton);
+    evas_object_smart_callback_add(lButton,
+                                   EVAS_SMART_CALLBACK_CLICKED,
+                                   buttonCallback,
+                                   static_cast<void *>(authData));
+
+    Evas_Object* rButton= elm_button_add(popup);
+    elm_object_text_set(rButton, TEXT_CANCEL);
+    elm_object_style_set(rButton, STYLE_POPUP_BUTTON_DEFAULT);
+    elm_object_part_content_set(popup, PART_BUTTON2, rButton);
+    evas_object_smart_callback_add(rButton,
+                                   EVAS_SMART_CALLBACK_CLICKED,
+                                   buttonCallback,
+                                   static_cast<void *>(authData));
+
+    evas_object_show(popup);
+}
+
+Evas_Object* createEditLayout(Evas_Object* parent, bool isPasswordEdit)
+{
+    Evas_Object* layout = elm_layout_add(parent);
+    elm_layout_theme_set(layout, LAYOUT, THEME_EDITFIELD, THEME_DEFAULT);
+    Evas_Object* entry = elm_entry_add(layout);
+    elm_object_part_content_set(layout, ELM_SWALLOW_CONTENT, entry);
+    elm_object_signal_emit(layout, ELM_SIGNAL_STATE_GUIDETEXT_HIDE, ELM);
+    evas_object_data_set(layout, ERASER, reinterpret_cast<void *>(EINA_TRUE));
+
+    evas_object_smart_callback_add(entry,
+                                   EVAS_SMART_CALLBACK_CHANGED,
+                                   editChangedCallback,
+                                   layout);
+    evas_object_smart_callback_add(entry,
+                                   EVAS_SMART_CALLBACK_PREEDIT_CHANGED,
+                                   editChangedCallback,
+                                   layout);
+    evas_object_smart_callback_add(entry,
+                                   EVAS_SMART_CALLBACK_FOCUSED,
+                                   editFocusedCallback,
+                                   layout);
+    evas_object_smart_callback_add(entry,
+                                   EVAS_SMART_CALLBACK_UNFOCUSED,
+                                   editUnfocusedCallback,
+                                   layout);
+    elm_object_signal_callback_add(layout,
+                                   ELM_SIGNAL_ERASER_CLICKED,
+                                   ELM,
+                                   eraserClickedCallback,
+                                   entry);
+
+    if (isPasswordEdit) {
+        elm_entry_password_set(entry, EINA_TRUE);
+    } else {
+        elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_NONE);
+        evas_object_data_set(layout, ERASER, reinterpret_cast<void *>(EINA_TRUE));
+        elm_object_signal_emit(layout, ELM_SIGNAL_STATE_ERASER_SHOW, ELM);
+    }
+    elm_entry_text_style_user_push(
+        layout,
+        STYLE_DEFAULT_EDITFIELD);
+    return layout;
+}
+
+void editChangedCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
+{
+    Assert(data);
+    Evas_Object* layout = static_cast<Evas_Object *>(data);
+
+    Assert(obj);
+    if (elm_object_focus_get(obj)) {
+        if (elm_entry_is_empty(obj)) {
+            elm_object_signal_emit(layout, ELM_SIGNAL_STATE_HIDE_SHOW, ELM);
+        } else {
+            elm_object_signal_emit(layout, ELM_SIGNAL_STATE_ERASER_SHOW, ELM);
+        }
+    }
+}
+
+void editFocusedCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
+{
+    Assert(data);
+    Evas_Object* layout = static_cast<Evas_Object *>(data);
+
+    Assert(obj);
+    if (!elm_entry_is_empty(obj)) {
+        elm_object_signal_emit(layout, ELM_SIGNAL_STATE_ERASER_SHOW, ELM);
+    }
+}
+void editUnfocusedCallback(void* data,
+                                  Evas_Object* /*obj*/,
+                                  void* /*eventInfo*/)
+{
+    Assert(data);
+    Evas_Object* layout = static_cast<Evas_Object *>(data);
+    elm_object_signal_emit(layout, ELM_SIGNAL_STATE_HIDE_SHOW, ELM);
+}
+
+void eraserClickedCallback(void* data,
+                           Evas_Object* /*obj*/,
+                           const char* /*emission*/,
+                           const char* /*source*/)
+{
+    Assert(data);
+    Evas_Object* entry = static_cast<Evas_Object *>(data);
+    elm_entry_entry_set(entry, "");
+}
+
+Evas_Object* getEvasObjectByWidgetName(Evas_Object* obj, const char* name)
+{
+    Assert(obj);
+    Evas_Object* current = elm_object_parent_widget_get(obj);
+    while (strcmp(elm_object_widget_type_get(current), name)) {
+        current = elm_object_parent_widget_get(current);
+        if (!current) {
+            return NULL;
+        }
+    }
+    return current;
+}
+
+void buttonCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
+{
+    LogDebug("popupCallback");
+    Assert(data);
+    authenticationData* authData = static_cast<authenticationData *>(data);
+
+    Assert(obj);
+    Evas_Object* popup = getEvasObjectByWidgetName(obj, WIDGET_NAME_POPUP);
+
+    bool allow = !strcmp(TEXT_OK, elm_object_text_get(obj));
+    if (allow) {
+        const char* id =
+            elm_entry_entry_get(
+                elm_object_part_content_get(authData->m_idLayout,
+                                            ELM_SWALLOW_CONTENT));
+        const char* pw =
+            elm_entry_entry_get(
+                elm_object_part_content_get(authData->m_passLayout,
+                                            ELM_SWALLOW_CONTENT));
+        LogDebug("id = [" << id << "], password = [" << pw << "]");
+        ewk_auth_challenge_credential_use(authData->m_authChallenge,
+                                          const_cast<char *>(id),
+                                          const_cast<char *>(pw));
+    } else {
+        ewk_auth_challenge_credential_cancel(authData->m_authChallenge);
+    }
+
+    evas_object_hide(popup);
+    evas_object_del(popup);
+    delete authData;
+}
+} // namespace
+
+void AuthenticationChallengeSupport::authenticationChallengeRequest(
+    Evas_Object* webview,
+    std::string url,
+    void* data)
+{
+    LogDebug("authenticationChallengeRequest called");
+    authenticationData* authData = new authenticationData();
+    Assert(webview);
+    authData->m_navi = getEvasObjectByWidgetName(webview,
+                                                 WIDGET_NAME_NAVIFRAME);
+
+    Assert(data);
+    authData->m_authChallenge = static_cast<Ewk_Auth_Challenge*>(data);
+
+    // create body text
+    // TODO : The text should be translated
+    const char* authRealm =
+        ewk_auth_challenge_realm_get(authData->m_authChallenge);
+    if (authRealm != NULL) {
+        authData->m_bodyText =
+            std::string(AUTHENTICATION_CHALLENGE_BODY_PRETEXT) +
+            std::string(url) +
+            std::string(AUTHENTICATION_CHALLENGE_BODY_MIDDLETEXT) +
+            std::string(TEXT_DOUBLE_QUOTATION_MARKS) +
+            std::string(authRealm) +
+            std::string(TEXT_DOUBLE_QUOTATION_MARKS);
+    }
+    ewk_auth_challenge_suspend(authData->m_authChallenge);
+
+    // ask to user
+    askUserInformation(authData);
+}
+} // namespace ViewModule
  *    limitations under the License.
  */
 /**
- * @file    view_logic_filesystem_support.h
+ * @file    view_logic_authentication_challenge_support.h
  * @author  Jihoon Chung (jihoon.chung@samsung.com)
  */
 
-#ifndef VIEW_LOGIC_FILESYSTEM_SUPPORT_H_
-#define VIEW_LOGIC_FILESYSTEM_SUPPORT_H_
+#ifndef VIEW_LOGIC_AUTHENTICATION_CHALLENGE_SUPPORT_H_
+#define VIEW_LOGIC_AUTHENTICATION_CHALLENGE_SUPPORT_H_
 
-#include <memory.h>
+#include <string>
 #include <Elementary.h>
 
-namespace SecurityOriginDB {
-    class SecurityOriginDAO;
-}
-
 namespace ViewModule {
-namespace FileSystemSupport {
-
-void fileSystemPermissionRequest(
-        Evas_Object* window,
-        SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
-        void* data);
-
-} // namespace FileSystemSupport
+namespace AuthenticationChallengeSupport {
+void authenticationChallengeRequest(
+    Evas_Object* webview,
+    std::string url,
+    void* data);
+} // namespace AuthenticationChallengeSupport
 } // namespace ViewModule
 
-#endif // VIEW_LOGIC_FILESYSTEM_SUPPORT_H_
+#endif // VIEW_LOGIC_AUTHENTICATION_CHALLENGE_SUPPORT_H_
\ No newline at end of file
diff --git a/src/view/webkit/view_logic_certificate_confirm_support.cpp b/src/view/webkit/view_logic_certificate_confirm_support.cpp
new file mode 100755 (executable)
index 0000000..34d2d21
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * 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    view_logic_certificate_confirm_support.cpp
+ * @author  Leerang Song (leerang.song@samsung.com)
+ */
+
+#include "view_logic_certificate_confirm_support.h"
+
+#include <string>
+#include <sstream>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <wrt-commons/certificate-dao/certificate_dao_types.h>
+#include <wrt-commons/certificate-dao/certificate_dao.h>
+#include <EWebKit2.h>
+#include <common/view_logic_certificate_support.h>
+#include <Elementary.h>
+
+namespace ViewModule {
+namespace CertificateConfirmSupport {
+using namespace CertificateDB;
+using namespace ViewModule::CertificateSupportUtil;
+
+namespace {
+const char* const CERTIFICATION_ASK_BODY =
+    "This site's security certificate is not trusted! Do you acess this site?";
+const char* const CERTIFICATION_ASK_CHECK = "Don't ask again";
+
+// function declare
+void askUserForCertificatePermission(
+    Evas_Object* window,
+    PermissionData* data);
+static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
+
+void askUserForCertificatePermission(
+    Evas_Object* window,
+    PermissionData* data)
+{
+    LogDebug("askUserForCertificatePermission called");
+    Evas_Object* popup = createPopup(window,
+                                     CERTIFICATION_ASK_BODY,
+                                     CERTIFICATION_ASK_CHECK,
+                                     popupCallback,
+                                     data);
+
+    if (popup == NULL) {
+        LogError("Fail to create popup object");
+        delete data;
+        return;
+    } else {
+        evas_object_show(popup);
+    }
+}
+
+void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
+{
+    LogDebug("popupCallback");
+    Assert(data);
+    PermissionData* permData = static_cast<PermissionData*>(data);
+    Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
+        static_cast<Ewk_Certificate_Policy_Decision*>(permData->m_data);
+
+    Evas_Object* popup = getPopup(obj);
+    Result result = getResult(obj);
+
+    if (result != RESULT_UNKNOWN) {
+        permData->m_certiDao->setCertificateData(permData->m_certiData,
+                                                     result);
+    }
+    Eina_Bool ret =
+        (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
+        EINA_TRUE : EINA_FALSE;
+
+    ewk_certificate_policy_decision_allowed_set(
+        certificatePolicyDecision,
+        ret);
+    delete permData;
+    evas_object_hide(popup);
+    evas_object_del(popup);
+}
+} // namespace
+
+void certificatePermissionRequest(
+    Evas_Object* window,
+    CertificateDB::CertificateDAO* certificateDAO,
+    void* data)
+{
+    LogDebug("certificationPermissionRequest called");
+    Assert(certificateDAO);
+    Assert(data);
+
+    Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
+        static_cast<Ewk_Certificate_Policy_Decision*>(data);
+    ewk_certificate_policy_decision_suspend(certificatePolicyDecision);
+    Assert(certificatePolicyDecision);
+
+    CertificateData certificateData(
+             DPL::FromUTF8String(
+                ewk_certificate_policy_decision_certificate_pem_get(
+                     certificatePolicyDecision)));
+
+    // check cache database
+    Result result = certificateDAO->getResult(certificateData);
+
+    if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
+        LogDebug("allow");
+        ewk_certificate_policy_decision_allowed_set(
+            certificatePolicyDecision,
+            EINA_TRUE);
+         return;
+   } else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
+        LogDebug("Deny");
+        ewk_certificate_policy_decision_allowed_set(
+            certificatePolicyDecision,
+            EINA_FALSE);
+         return;
+    }
+    // ask to user
+    PermissionData* permissionData =
+        new PermissionData(certificateDAO,
+                           certificateData,
+                           certificatePolicyDecision);
+    askUserForCertificatePermission(window, permissionData);
+    return;
+}
+}
+} // namespace ViewModule
old mode 100644 (file)
new mode 100755 (executable)
similarity index 60%
rename from src/view/webkit/view_logic_web_storage_support.h
rename to src/view/webkit/view_logic_certificate_confirm_support.h
index 537489d..8bd42ba
  *    limitations under the License.
  */
 /**
- * @file    view_logic_web_storage_support.h
- * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @file    view_logic_certificate_confirm_support.h
+ * @author  Leerang Song (leerang.song@samsung.com)
  */
 
-#ifndef VIEW_LOGIC_WEB_STORAGE_SUPPORT_H_
-#define VIEW_LOGIC_WEB_STORAGE_SUPPORT_H_
+#ifndef VIEW_LOGIC_CERTIFICATE_CONFIRM_SUPPORT_H_
+#define VIEW_LOGIC_CERTIFICATE_CONFIRM_SUPPORT_H_
 
 #include <memory.h>
 #include <Elementary.h>
 
-namespace SecurityOriginDB {
-    class SecurityOriginDAO;
+namespace CertificateDB {
+class CertificateDAO;
 }
 
 namespace ViewModule {
-namespace WebStorageSupport {
-
-void webStorageCreatePermissionRequest(
-        Evas_Object* window,
-        SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
-        void* data);
-
-} // namespace WebStorageSupport
+namespace CertificateConfirmSupport {
+void certificatePermissionRequest(
+    Evas_Object* window,
+    CertificateDB::CertificateDAO* certificateDAO,
+    void* data);
+}
 } // namespace ViewModule
 
-#endif // VIEW_LOGIC_WEB_STORAGE_SUPPORT_H_
\ No newline at end of file
+#endif
diff --git a/src/view/webkit/view_logic_filesystem_support.cpp b/src/view/webkit/view_logic_filesystem_support.cpp
deleted file mode 100644 (file)
index 55e9949..0000000
+++ /dev/null
@@ -1,140 +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    view_logic_filesystem_support.cpp
- * @author  Jihoon Chung (jihoon.chung@samsung.com)
- */
-
-#include "view_logic_filesystem_support.h"
-
-#include <string>
-#include <dpl/log/log.h>
-#include <dpl/assert.h>
-#include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
-#include <wrt-commons/security-origin-dao/security_origin_dao.h>
-#include <EWebKit2.h>
-#include <common/view_logic_security_origin_support.h>
-#include <Elementary.h>
-
-namespace ViewModule {
-
-using namespace SecurityOriginDB;
-using namespace ViewModule::SecurityOriginSupportUtil;
-
-namespace {
-const char* const FILESYSTEM_USE_ASK_TITLE = "Use FileSystem?";
-const char* const FILESYSTEM_USE_ASK_BODY_PREFIX = "Do you want to allow ";
-const char* const FILESYSTEM_USE_ASK_BODY_POSTFIX =
-    " to use persistent filesystem?";
-const char* const FILESYSTEM_USE_ASK_CHECK = "Don't ask again";
-
-// function declare
-void askUserForFileSystemPermission(
-    Evas_Object* window,
-    PermissionData* data);
-static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
-
-void askUserForFileSystemPermission(Evas_Object* window, PermissionData* data)
-{
-    LogDebug("askUserForFileSystemPermission called");
-    std::string body =
-        FILESYSTEM_USE_ASK_BODY_PREFIX +
-        DPL::ToUTF8String(data->m_originData.origin.host) +
-        FILESYSTEM_USE_ASK_BODY_POSTFIX;
-    Evas_Object* popup = createPopup(window,
-                                     body.c_str(),
-                                     FILESYSTEM_USE_ASK_CHECK,
-                                     popupCallback,
-                                     data);
-    if (popup == NULL) {
-        LogError("Fail to create popup object");
-        delete data;
-        return;
-    } else {
-        evas_object_show(popup);
-    }
-}
-
-void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
-{
-    LogDebug("popupCallback");
-    Assert(data);
-    PermissionData* permData = static_cast<PermissionData*>(data);
-    Ewk_Context_File_System_Permission* fileSystemPermission =
-            static_cast<Ewk_Context_File_System_Permission*>(permData->m_data);
-
-    Evas_Object* popup = getPopup(obj);
-    Result result = getResult(obj);
-
-    if (result != RESULT_UNKNOWN) {
-        permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
-    }
-    Eina_Bool ret =
-        (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
-            EINA_TRUE : EINA_FALSE;
-    ewk_context_file_system_permission_allow_set(fileSystemPermission,
-                                                 ret);
-    delete permData;
-    evas_object_hide(popup);
-    evas_object_del(popup);
-}
-} // namespace
-
-void FileSystemSupport::fileSystemPermissionRequest(
-    Evas_Object* window,
-    SecurityOriginDAO* securityOriginDAO,
-    void* data)
-{
-    LogDebug("fileSystemPermissionRequest called");
-    Assert(securityOriginDAO);
-    Assert(data);
-    Ewk_Context_File_System_Permission* fileSystemPermission =
-        static_cast<Ewk_Context_File_System_Permission*>(data);
-    Ewk_Security_Origin* ewkOrigin =
-        ewk_context_file_system_permission_origin_get(
-        fileSystemPermission);
-    Assert(ewkOrigin);
-
-    SecurityOriginData securityOriginData(
-        FEATURE_FILE_SYSTEM_ACCESS,
-        Origin(
-            DPL::FromUTF8String(ewk_security_origin_protocol_get(ewkOrigin)),
-            DPL::FromUTF8String(ewk_security_origin_host_get(ewkOrigin)),
-            ewk_security_origin_port_get(ewkOrigin)));
-
-    // check cache database
-    Result result = securityOriginDAO->getResult(securityOriginData);
-    if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
-        LogDebug("permit");
-        ewk_context_file_system_permission_allow_set(fileSystemPermission,
-                                                     EINA_TRUE);
-        return;
-    } else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
-        LogDebug("deny");
-        ewk_context_file_system_permission_allow_set(fileSystemPermission,
-                                                     EINA_FALSE);
-        return;
-    }
-
-    // ask to user
-    PermissionData* permissionData =
-        new PermissionData(securityOriginDAO,
-                           securityOriginData,
-                           fileSystemPermission);
-    askUserForFileSystemPermission(window, permissionData);
-    return;
-}
-} // namespace ViewModule
index 197d658..9729833 100644 (file)
@@ -33,7 +33,6 @@
 namespace ViewModule {
 namespace GeolocationSupport {
 namespace Webkit2 {
-
 using namespace SecurityOriginDB;
 using namespace ViewModule::SecurityOriginSupportUtil;
 
@@ -73,21 +72,20 @@ void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
     LogDebug("popupCallback");
     Assert(data);
     PermissionData* permData = static_cast<PermissionData*>(data);
-    Ewk_Geolocation_Permission_Data* permissionRequest =
-            static_cast<Ewk_Geolocation_Permission_Data*>(permData->m_data);
+    Ewk_Geolocation_Permission_Request* permissionRequest =
+        static_cast<Ewk_Geolocation_Permission_Request*>(permData->m_data);
 
     Evas_Object* popup = getPopup(obj);
     Result result = getResult(obj);
 
     if (result != RESULT_UNKNOWN) {
-        permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
+        permData->m_originDao->setSecurityOriginData(permData->m_originData,
+                                                     result);
     }
     Eina_Bool ret =
         (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
-            EINA_TRUE : EINA_FALSE;
-    ewk_geolocation_permission_request_allow_set(
-                ewk_geolocation_permission_request_get(permissionRequest),
-                ret);
+        EINA_TRUE : EINA_FALSE;
+    ewk_geolocation_permission_request_set(permissionRequest, ret);
     delete permData;
     evas_object_hide(popup);
     evas_object_del(popup);
@@ -95,15 +93,15 @@ void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
 } // namespace
 
 void geolocationPermissionRequest(
-        Evas_Object* window,
-        SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
-        void* data)
+    Evas_Object* window,
+    SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
+    void* data)
 {
     LogDebug("geolocationPermissionRequest called");
     Assert(securityOriginDAO);
     Assert(data);
-    Ewk_Geolocation_Permission_Data* permissionRequest =
-        static_cast<Ewk_Geolocation_Permission_Data*>(data);
+    Ewk_Geolocation_Permission_Request* permissionRequest =
+        static_cast<Ewk_Geolocation_Permission_Request*>(data);
     const Ewk_Security_Origin* ewkOrigin =
         ewk_geolocation_permission_request_origin_get(
             permissionRequest);
@@ -120,18 +118,16 @@ void geolocationPermissionRequest(
     Result result = securityOriginDAO->getResult(securityOriginData);
     if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
         LogDebug("allow");
-        ewk_geolocation_permission_request_allow_set(
-            ewk_geolocation_permission_request_get(permissionRequest),
-            EINA_TRUE);
+        ewk_geolocation_permission_request_set(permissionRequest, EINA_TRUE);
         return;
     } else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
         LogDebug("deny");
-        ewk_geolocation_permission_request_allow_set(
-            ewk_geolocation_permission_request_get(permissionRequest),
-            EINA_FALSE);
+        ewk_geolocation_permission_request_set(permissionRequest, EINA_FALSE);
         return;
     }
 
+    ewk_geolocation_permission_request_suspend(permissionRequest);
+
     // ask to user
     PermissionData* permissionData =
         new PermissionData(securityOriginDAO,
@@ -141,6 +137,5 @@ void geolocationPermissionRequest(
     return;
 }
 }
-
 } // namespace GeolocationSupport
 } // namespace ViewModule
index bbe2600..e1869b6 100644 (file)
 #include <Elementary.h>
 
 namespace SecurityOriginDB {
-    class SecurityOriginDAO;
+class SecurityOriginDAO;
 }
 
 namespace ViewModule {
 namespace GeolocationSupport {
 namespace Webkit2 {
-
 void geolocationPermissionRequest(
-        Evas_Object* window,
-        SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
-        void* data);
-
+    Evas_Object* window,
+    SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
+    void* data);
 }
 } // namespace GeolocationSupport
 } // namespace ViewModule
index cca7fd5..74f79d8 100644 (file)
@@ -40,18 +40,21 @@ char const * const TIZEN_CHANGE_USERAGNET = "tizen://changeUA";
 const int ORIENTATION_LANDSCAPE_ANGLE = 270;
 const int ORIENTATION_PORTAIT_ANGLE = 0;
 
+const int W3C_SCREEN_ORI_PORTRAIT_PRIMARY = 0;
+const int W3C_SCREEN_ORI_LANDSCAPE_PRIMARY = 90;
+
 static Eina_Bool exitAppIdlerCallback(void* /*data*/)
 {
     // webapp termination
     ewk_shutdown();
     elm_exit();
-    return ECORE_CALLBACK_CANCEL;}
-
+    return ECORE_CALLBACK_CANCEL;
+}
 } // namespace
 
 bool SchemeSupport::HandleUri(
-        const char* uri,
-        ViewModule::SchemeActionMap::NavigationContext context)
+    const char* uri,
+    ViewModule::SchemeActionMap::NavigationContext context)
 {
     return ViewModule::SchemeActionMap::HandleUri(uri,
                                                   context,
@@ -86,6 +89,7 @@ bool SchemeSupport::HandleTizenScheme(const char* uri,
     {
         LogInfo("Tizen scheme: " << uri << " orientation landscape");
         elm_win_rotation_with_resize_set(window, ORIENTATION_LANDSCAPE_ANGLE);
+        ewk_view_orientation_send(wkView, W3C_SCREEN_ORI_LANDSCAPE_PRIMARY);
         return true;
     } else if (strncmp(uri,
                        TIZEN_ORIENTATION_PORTAIT,
@@ -93,6 +97,7 @@ bool SchemeSupport::HandleTizenScheme(const char* uri,
     {
         LogInfo("Tizen scheme: " << uri << " orientation portait");
         elm_win_rotation_with_resize_set(window, ORIENTATION_PORTAIT_ANGLE);
+        ewk_view_orientation_send(wkView, W3C_SCREEN_ORI_PORTRAIT_PRIMARY);
         return true;
     } else if (strncmp(uri,
                        TIZEN_ORIENTATION_RESET,
@@ -100,16 +105,18 @@ bool SchemeSupport::HandleTizenScheme(const char* uri,
     {
         LogInfo("Tizen scheme: " << uri << " reset");
         elm_win_rotation_with_resize_set(window, ORIENTATION_PORTAIT_ANGLE);
+        ewk_view_orientation_send(wkView, W3C_SCREEN_ORI_PORTRAIT_PRIMARY);
         return true;
     } else if (strncmp(uri,
                        TIZEN_CHANGE_USERAGNET,
                        strlen(TIZEN_CHANGE_USERAGNET)) == 0)
     {
         LogInfo("Tizen scheme: " << uri << " change UA");
-        const char* userAgentString = strstr(uri, "=") + 1;
+        const char* userAgentString = strstr(uri, "=");
         if (NULL == userAgentString) {
             LogDebug("UA string is NULL");
         } else {
+            userAgentString++;
             LogDebug("Setting custom user agent as: " << userAgentString);
             ewk_view_user_agent_set(wkView, userAgentString);
         }
@@ -139,8 +146,7 @@ bool SchemeSupport::filterURIByScheme(Ewk_Policy_Decision* policyDecision,
         ewk_frame_is_main_frame(ewk_policy_decision_frame_get(policyDecision));
 
     using namespace ViewModule::SchemeActionMap;
-    if (HandleTizenScheme(url, window, wkView))
-    {
+    if (HandleTizenScheme(url, window, wkView)) {
         LogDebug("Scheme is tizen scheme");
         return false;
     }
index 0072c0b..73a9560 100644 (file)
@@ -30,7 +30,8 @@
 class WindowData;
 class WidgetModel;
 
-class SchemeSupport {
+class SchemeSupport
+{
   public:
     explicit SchemeSupport(WrtDB::AppType type) : m_type(type) {}
     bool HandleTizenScheme(const char* uri,
@@ -44,6 +45,7 @@ class SchemeSupport {
                            WidgetModel* model,
                            Evas_Object* window,
                            Evas_Object* wkView);
+
   private:
     WrtDB::AppType m_type;
 };
index 445f754..15516ea 100644 (file)
 #include <string>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao.h>
 #include <Elementary.h>
 #include <EWebKit2.h>
+#include <common/view_logic_security_origin_support.h>
 
 namespace ViewModule {
-
+using namespace SecurityOriginDB;
+using namespace ViewModule::SecurityOriginSupportUtil;
 namespace {
 const char* const USERMEDIA_USE_ASK_BODY =
     "This application wants to use your media";
 
 // function declare
-void askUserForUsermediaPermission(Evas_Object* window, void* data);
+void askUserForUsermediaPermission(Evas_Object* window, PermissionData* data);
 Evas_Object* getPopup(Evas_Object* button);
 static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
 
-void askUserForUsermediaPermission(Evas_Object* window, void* data)
+void askUserForUsermediaPermission(Evas_Object* window, PermissionData* data)
 {
     LogDebug("askUserForUsermediaPermission called");
 
@@ -75,30 +79,57 @@ void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
 {
     LogDebug("popupCallback");
     Assert(data);
-    Ewk_User_Media_Permission* usermediaPermission =
-        static_cast<Ewk_User_Media_Permission*>(data);
+    PermissionData* permData = static_cast<PermissionData*>(data);
+    Ewk_User_Media_Permission_Request* permissionRequest =
+        static_cast<Ewk_User_Media_Permission_Request*>(permData->m_data);
 
     Assert(obj);
     Evas_Object* popup = getPopup(obj);
     Assert(popup);
-    bool allow = !strcmp("Allow", elm_object_text_get(obj));
 
+    bool allow = !strcmp("Allow", elm_object_text_get(obj));
     Eina_Bool ret = allow ? EINA_TRUE : EINA_FALSE;
-    ewk_user_media_permission_set(usermediaPermission, ret);
-
+    ewk_user_media_permission_request_set(permissionRequest, ret);
+    delete permData;
     evas_object_hide(popup);
     evas_object_del(popup);
 }
 } // namespace
 
 void UsermediaSupport::usermediaPermissionRequest(Evas_Object* window,
-                                                   void* data)
+                                                  SecurityOriginDAO* securityOriginDAO,
+                                                  void* data)
 {
     LogDebug("usermediaPermissionRequest called");
-    Assert(window);
+    Assert(securityOriginDAO);
     Assert(data);
+    Ewk_User_Media_Permission_Request* permissionRequest =
+        static_cast<Ewk_User_Media_Permission_Request*>(data);
+
+    SecurityOriginData securityOriginData(
+        FEATURE_USER_MEDIA,
+        Origin(DPL::FromUTF8String(""), DPL::FromUTF8String(""), 0));
+
+    // In case of usermedia ewk doesn't support origin data
+    // cache data also only store allow data by privilege
+    Result result = securityOriginDAO->getResult(securityOriginData);
+    if (RESULT_ALLOW_ALWAYS == result) {
+        LogDebug("allow");
+        ewk_user_media_permission_request_set(permissionRequest, EINA_TRUE);
+        return;
+    } else if (RESULT_DENY_ALWAYS == result) {
+        LogDebug("deny");
+        ewk_user_media_permission_request_set(permissionRequest, EINA_FALSE);
+        return;
+    }
+
+    ewk_user_media_permission_request_suspend(permissionRequest);
     // ask to user
-    askUserForUsermediaPermission(window, data);
+    PermissionData* permissionData =
+        new PermissionData(securityOriginDAO,
+                           securityOriginData,
+                           data);
+    askUserForUsermediaPermission(window, permissionData);
     return;
 }
 } // namespace ViewModule
index 27f5e70..9c9b05f 100644 (file)
 #ifndef VIEW_LOGIC_USERMEDIA_SUPPORT_H_
 #define VIEW_LOGIC_USERMEDIA_SUPPORT_H_
 
+#include <memory>
 #include <Elementary.h>
 
+//Forward declarations
+namespace SecurityOriginDB {
+class SecurityOriginDAO;
+}
+
 namespace ViewModule {
 namespace UsermediaSupport {
-
 void usermediaPermissionRequest(
-        Evas_Object* window,
-        void* data);
-
+    Evas_Object* window,
+    SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
+    void* data);
 } // namespace UsermediaSupport
 } // namespace ViewModule
 
diff --git a/src/view/webkit/view_logic_utils.cpp b/src/view/webkit/view_logic_utils.cpp
deleted file mode 100644 (file)
index 49dbb41..0000000
+++ /dev/null
@@ -1,76 +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    view_logic_utils.cpp
- * @author  Lukasz Marek (l.marek@samsung.com)
- * @brief   Implementation file of utils API used by ViewLogic
- */
-
-#include "view_logic_utils.h"
-
-namespace ViewModule {
-namespace Utils {
-
-DPL::OptionalString toString(WKStringRef str)
-{
-    if (WKStringIsEmpty(str)) {
-        return DPL::OptionalString::Null;
-    }
-    size_t size = WKStringGetMaximumUTF8CStringSize(str);
-    char buffer[size + 1];
-    WKStringGetUTF8CString(str, buffer, size + 1);
-    return DPL::FromUTF8String(buffer);
-}
-
-DPL::OptionalString toString(WKURLRef url)
-{
-    WKStringRef urlStr = WKURLCopyString(url);
-    DPL::OptionalString str = toString(urlStr);
-    WKRelease(urlStr);
-    return str;
-}
-
-DPL::OptionalString toString(WKURLRequestRef req)
-{
-    WKURLRef reqUrl = WKURLRequestCopyURL(req);
-    DPL::OptionalString str = toString(reqUrl);
-    WKRelease(reqUrl);
-    return str;
-}
-
-DPL::OptionalString toString(WKFrameRef req)
-{
-    WKURLRef reqUrl = WKFrameCopyURL(req);
-    DPL::OptionalString str = toString(reqUrl);
-    WKRelease(reqUrl);
-    return str;
-}
-
-DPL::OptionalString toString(WKErrorRef err)
-{
-    WKStringRef domErr = WKErrorCopyDomain(err);
-    WKStringRef desc = WKErrorCopyLocalizedDescription(err);
-    DPL::String str =
-        (WKStringIsEmpty(domErr) ? L"null" : *toString(domErr)) +
-        L"\n" +
-        (WKStringIsEmpty(desc) ? L"null" : *toString(desc));
-    WKRelease(domErr);
-    WKRelease(desc);
-    return str;
-}
-
-} // namespace Utils
-} // namespace ViewModule
diff --git a/src/view/webkit/view_logic_utils.h b/src/view/webkit/view_logic_utils.h
deleted file mode 100644 (file)
index 4908263..0000000
+++ /dev/null
@@ -1,41 +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    view_logic_utils.h
- * @author  Lukasz Marek (l.marek@samsung.com)
- * @brief   Header file of utils API used by ViewLogic
- */
-
-#ifndef VIEW_LOGIC_UTILS_H_
-#define VIEW_LOGIC_UTILS_H_
-
-#include <WebKit2.h>
-#include <dpl/string.h>
-#include <dpl/optional_typedefs.h>
-
-namespace ViewModule {
-namespace Utils {
-
-DPL::OptionalString toString(WKStringRef str);
-DPL::OptionalString toString(WKURLRef url);
-DPL::OptionalString toString(WKURLRequestRef req);
-DPL::OptionalString toString(WKFrameRef req);
-DPL::OptionalString toString(WKErrorRef err);
-
-} // namespace Utils
-} // namespace ViewModule
-
-#endif /* VIEW_LOGIC_UTILS_H_ */
index 11c3924..2284dbe 100644 (file)
@@ -40,35 +40,13 @@ const char* const WEB_NOTIFICATION_ASK_BODY_PREFIX = "Do you want to allow ";
 const char* const WEB_NOTIFICATION_ASK_BODY_POSTFIX =
     " to use web notificaion?";
 const char* const WEB_NOTIFICATION_ASK_CHECK = "Don't ask again";
-
 }
 
 namespace ViewModule {
 namespace WebNotification {
-
 using namespace SecurityOriginDB;
 using namespace ViewModule::SecurityOriginSupportUtil;
 
-class WebNotificationPermissionData
-    : public ViewModule::SecurityOriginSupportUtil::PermissionData
-{
-  public:
-    Ewk_Context* m_ewkContext;
-
-    WebNotificationPermissionData(
-        SecurityOriginDB::SecurityOriginDAO* originDao,
-        SecurityOriginDB::SecurityOriginData originData,
-        Ewk_Context* ewkContext,
-        void* data) :
-            ViewModule::SecurityOriginSupportUtil::PermissionData(
-                originDao,
-                originData,
-                data),
-            m_ewkContext(ewkContext)
-    {
-    };
-};
-
 bool notificationShow(WebNotificationDataPtr notiData);
 bool notificationHide(WebNotificationDataPtr notiData);
 bool isExternalUri(const std::string &pattern, const std::string &uri);
@@ -76,7 +54,7 @@ bool downloadImage(WebNotificationDataPtr notiData);
 size_t curlWriteData(void *ptr, size_t size, size_t nmemb, FILE *stream);
 void askUserForWebNotificationPermission(
     Evas_Object* window,
-    WebNotificationPermissionData* data);
+    PermissionData* data);
 static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
 
 WebNotificationData::WebNotificationData(WidgetModel* widgetModel,
@@ -88,13 +66,11 @@ WebNotificationData::WebNotificationData(WidgetModel* widgetModel,
 }
 
 WebNotificationData::~WebNotificationData()
-{
-}
+{}
 
 void webNotificationPermissionRequest(
     Evas_Object* window,
     SecurityOriginDAO* securityOriginDAO,
-    Ewk_Context* ewkContext,
     void* data)
 {
     LogDebug("permissionRequest called");
@@ -117,24 +93,19 @@ void webNotificationPermissionRequest(
     Result result = securityOriginDAO->getResult(securityOriginData);
     if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
         LogDebug("allow");
-        ewk_notification_permission_request_response(ewkContext,
-                                                     request,
-                                                     EINA_TRUE);
+        ewk_notification_permission_request_set(request, EINA_TRUE);
         return;
     } else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
         LogDebug("deny");
-        ewk_notification_permission_request_response(ewkContext,
-                                                     request,
-                                                     EINA_FALSE);
+        ewk_notification_permission_request_set(request, EINA_FALSE);
         return;
     }
 
     // ask to user
-    WebNotificationPermissionData* permissionData =
-        new WebNotificationPermissionData(securityOriginDAO,
+    PermissionData* permissionData =
+        new PermissionData(securityOriginDAO,
                            securityOriginData,
-                           ewkContext,
-                           data);
+                           request);
 
     // suspend notification
     ewk_notification_permission_request_suspend(request);
@@ -160,7 +131,9 @@ bool notificationShow(WebNotificationDataPtr notiData)
     Try {
         // create notification
         noti_h = notification_new(
-            NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, notiData->m_id);
+                NOTIFICATION_TYPE_NOTI,
+                NOTIFICATION_GROUP_ID_NONE,
+                notiData->m_id);
         if (!noti_h) {
             LogError("Fail to notification_new");
             return false;
@@ -168,22 +141,22 @@ bool notificationShow(WebNotificationDataPtr notiData)
 
         // set notification title
         error = notification_set_text(
-            noti_h,
-            NOTIFICATION_TEXT_TYPE_TITLE,
-            notiData->m_title.c_str(),
-            NULL,
-            NOTIFICATION_VARIABLE_TYPE_NONE);
+                noti_h,
+                NOTIFICATION_TEXT_TYPE_TITLE,
+                notiData->m_title.c_str(),
+                NULL,
+                NOTIFICATION_VARIABLE_TYPE_NONE);
         if (error != NOTIFICATION_ERROR_NONE) {
             ThrowMsg(Exception::NotificationShowError, "Fail to set title");
         }
 
         // set notification content
         error = notification_set_text(
-            noti_h,
-            NOTIFICATION_TEXT_TYPE_CONTENT,
-            notiData->m_body.c_str(),
-            NULL,
-            NOTIFICATION_VARIABLE_TYPE_NONE);
+                noti_h,
+                NOTIFICATION_TEXT_TYPE_CONTENT,
+                notiData->m_body.c_str(),
+                NULL,
+                NOTIFICATION_VARIABLE_TYPE_NONE);
         if (error != NOTIFICATION_ERROR_NONE) {
             ThrowMsg(Exception::NotificationShowError,
                      "Fail to set content:" << error);
@@ -202,9 +175,9 @@ bool notificationShow(WebNotificationDataPtr notiData)
         // In this case, set to default package image.
         if (true == validIconURL) {
             error = notification_set_image(
-                noti_h,
-                NOTIFICATION_IMAGE_TYPE_ICON,
-                notiData->m_iconURL.c_str());
+                    noti_h,
+                    NOTIFICATION_IMAGE_TYPE_ICON,
+                    notiData->m_iconURL.c_str());
             if (error != NOTIFICATION_ERROR_NONE) {
                 ThrowMsg(Exception::NotificationShowError,
                          "Fail to free notification: " << error);
@@ -226,8 +199,8 @@ bool notificationShow(WebNotificationDataPtr notiData)
         if (noti_h) {
             error = notification_free(noti_h);
             if (error != NOTIFICATION_ERROR_NONE) {
-                        ThrowMsg(Exception::NotificationShowError,
-                                 "Fail to free notification: " << error);
+                ThrowMsg(Exception::NotificationShowError,
+                         "Fail to free notification: " << error);
             }
             noti_h = NULL;
         }
@@ -270,8 +243,8 @@ bool downloadImage(WebNotificationDataPtr notiData)
     // download path is
     // /opt/apps/tizen_id/data + '/' + filename
     std::string downloadPath =
-    DPL::ToUTF8String(
-            notiData->m_widgetModel->PersistentStoragePath.Get()) +  "/";
+        DPL::ToUTF8String(
+            notiData->m_widgetModel->PersistentStoragePath.Get()) + "/";
     LogDebug("downloadPath " << downloadPath);
 
     // Make valid filename
@@ -319,7 +292,7 @@ bool downloadImage(WebNotificationDataPtr notiData)
         }
         fclose(fp);
         curl_easy_cleanup(curl);
-    } Catch (DPL::Exception) {
+    } Catch(DPL::Exception) {
         LogError(_rethrown_exception.GetMessage());
         fclose(fp);
         curl_easy_cleanup(curl);
@@ -339,7 +312,7 @@ size_t curlWriteData(void *ptr, size_t size, size_t nmemb, FILE *stream)
 
 void askUserForWebNotificationPermission(
     Evas_Object* window,
-    WebNotificationPermissionData* data)
+    PermissionData* data)
 {
     LogDebug("askUserForWebNotificationPermission called");
     std::string body =
@@ -364,8 +337,7 @@ void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
 {
     LogDebug("popupCallback");
     Assert(data);
-    WebNotificationPermissionData* permData =
-        static_cast<WebNotificationPermissionData*>(data);
+    PermissionData* permData = static_cast<PermissionData*>(data);
     Ewk_Notification_Permission_Request* request =
         static_cast<Ewk_Notification_Permission_Request*>(permData->m_data);
 
@@ -373,19 +345,16 @@ void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
     Result result = getResult(obj);
 
     if (result != RESULT_UNKNOWN) {
-        permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
+        permData->m_originDao->setSecurityOriginData(permData->m_originData,
+                                                     result);
     }
     Eina_Bool ret =
         (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
-            EINA_TRUE : EINA_FALSE;
-    ewk_notification_permission_request_response(permData->m_ewkContext,
-                                                 request,
-                                                 ret);
+        EINA_TRUE : EINA_FALSE;
+    ewk_notification_permission_request_set(request, ret);
     delete permData;
     evas_object_hide(popup);
     evas_object_del(popup);
 }
-
-
 } // namespace WebNotification
 } //namespace ViewModule
index 2d8fd58..74c0d17 100644 (file)
 
 #include <memory>
 #include <stdint.h>
+#include <Elementary.h>
 #include <dpl/exception.h>
-#include <EWebKit2.h>
 
 //Forward declarations
 class WidgetModel;
 namespace SecurityOriginDB {
-    class SecurityOriginDAO;
+class SecurityOriginDAO;
 }
 
 namespace ViewModule {
 namespace WebNotification {
-
-class WebNotificationData {
+class WebNotificationData
+{
   public:
     WebNotificationData(WidgetModel* widgetModel, uint64_t id);
     virtual ~WebNotificationData();
@@ -51,7 +51,8 @@ class WebNotificationData {
 
 typedef std::shared_ptr<WebNotificationData> WebNotificationDataPtr;
 
-class Exception {
+class Exception
+{
   public:
     DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
     DECLARE_EXCEPTION_TYPE(Base, InitError)
@@ -62,10 +63,8 @@ class Exception {
 void webNotificationPermissionRequest(
     Evas_Object* window,
     SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
-    Ewk_Context* ewkContext,
     void* data);
 bool showWebNotification(WebNotificationDataPtr notiData);
-
 } // namespace SecuritySupport
 } // namespace WebNotification
 
diff --git a/src/view/webkit/view_logic_web_storage_support.cpp b/src/view/webkit/view_logic_web_storage_support.cpp
deleted file mode 100644 (file)
index f1bf7d2..0000000
+++ /dev/null
@@ -1,160 +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    view_logic_web_storage_support.cpp
- * @author  Jihoon Chung (jihoon.chung@samsung.com)
- */
-
-#include "view_logic_web_storage_support.h"
-
-#include <string>
-#include <sstream>
-#include <dpl/log/log.h>
-#include <dpl/assert.h>
-#include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
-#include <wrt-commons/security-origin-dao/security_origin_dao.h>
-#include <EWebKit2.h>
-#include <common/view_logic_security_origin_support.h>
-#include <Elementary.h>
-
-namespace ViewModule {
-
-using namespace SecurityOriginDB;
-using namespace ViewModule::SecurityOriginSupportUtil;
-
-namespace {
-const char* const WEB_STORAGE_CREATE_ASK_BODY_PREFIX = "Do you want to allow ";
-const char* const WEB_STORAGE_CREATE_ASK_BODY =
-    " to use up to ";
-const char* const WEB_STORAGE_CREATE_ASK_BODY_POSTFIX =
-    "MB of storage?";
-const char* const WEB_STORAGE_CREATE_ASK_CHECK = "Don't ask again";
-
-// function declare
-void askUserForWebStorageCreatePermission(
-    Evas_Object* window,
-    PermissionData* data);
-static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
-
-void askUserForWebStorageCreatePermission(
-    Evas_Object* window,
-    PermissionData* data)
-{
-    LogDebug("askUserForWebStorageCreatePermission called");
-    PermissionData* permData = static_cast<PermissionData*>(data);
-    Ewk_Context_Exceeded_Quota* exceededQuota =
-            static_cast<Ewk_Context_Exceeded_Quota*>(permData->m_data);
-
-    std::ostringstream size;
-    size << ewk_context_web_database_exceeded_quota_expected_usage_get(exceededQuota) /
-        (1024 * 1024);
-
-    std::string body =
-        WEB_STORAGE_CREATE_ASK_BODY_PREFIX +
-        DPL::ToUTF8String(data->m_originData.origin.host) +
-        WEB_STORAGE_CREATE_ASK_BODY +
-        size.str() +
-        WEB_STORAGE_CREATE_ASK_BODY_POSTFIX;
-
-    Evas_Object* popup = createPopup(window,
-                                     body.c_str(),
-                                     WEB_STORAGE_CREATE_ASK_CHECK,
-                                     popupCallback,
-                                     data);
-
-    if (popup == NULL) {
-        LogError("Fail to create popup object");
-        delete data;
-        return;
-    } else {
-        evas_object_show(popup);
-    }
-}
-
-void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
-{
-    LogDebug("popupCallback");
-    Assert(data);
-    PermissionData* permData = static_cast<PermissionData*>(data);
-    Ewk_Context_Exceeded_Quota* exceededQuota =
-            static_cast<Ewk_Context_Exceeded_Quota*>(permData->m_data);
-
-    Evas_Object* popup = getPopup(obj);
-    Result result = getResult(obj);
-
-    if (result != RESULT_UNKNOWN) {
-        permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
-    }
-    if  (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) {
-        ewk_context_web_database_exceeded_quota_new_quota_set(
-            exceededQuota,
-            ewk_context_web_database_exceeded_quota_expected_usage_get(
-                exceededQuota) +
-            10*(1024*1024)); //10MB
-    }
-
-    delete permData;
-    evas_object_hide(popup);
-    evas_object_del(popup);
-}
-} // namespace
-
-void WebStorageSupport::webStorageCreatePermissionRequest(
-    Evas_Object* window,
-    SecurityOriginDAO* securityOriginDAO,
-    void* data)
-{
-    LogDebug("webStorageCreatePermissionRequest called");
-    Assert(securityOriginDAO);
-    Assert(data);
-    Ewk_Context_Exceeded_Quota* exceededQuota =
-        static_cast<Ewk_Context_Exceeded_Quota*>(data);
-    Ewk_Security_Origin* ewkOrigin =
-        ewk_context_web_database_exceeded_quota_security_origin_get(
-            exceededQuota);
-    Assert(ewkOrigin);
-
-    SecurityOriginData securityOriginData(
-        FEATURE_WEB_DATABASE,
-        Origin(
-            DPL::FromUTF8String(ewk_security_origin_protocol_get(ewkOrigin)),
-            DPL::FromUTF8String(ewk_security_origin_host_get(ewkOrigin)),
-            ewk_security_origin_port_get(ewkOrigin)));
-
-    // check cache database
-    Result result = securityOriginDAO->getResult(securityOriginData);
-    if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
-        LogDebug("allow");
-        ewk_context_web_database_exceeded_quota_new_quota_set(
-                exceededQuota,
-                ewk_context_web_database_exceeded_quota_expected_usage_get(
-                    exceededQuota) +
-                10*(1024*1024)); //10MB
-        return;
-    } else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
-        LogDebug("deny");
-        return;
-    }
-
-    // ask to user
-    PermissionData* permissionData =
-        new PermissionData(securityOriginDAO,
-                           securityOriginData,
-                           exceededQuota);
-    askUserForWebStorageCreatePermission(window, permissionData);
-    return;
-}
-} // namespace ViewModule
index 3d11e47..6cdce5b 100644 (file)
@@ -23,7 +23,6 @@
 #include <dpl/log/log.h>
 #include <Elementary.h>
 
-
 SplashScreenSupport::SplashScreenSupport(Evas_Object* parent)
 {
     LogDebug("enter");
@@ -41,7 +40,8 @@ SplashScreenSupport::~SplashScreenSupport()
     LogDebug("enter");
 }
 
-bool SplashScreenSupport::createSplashScreen(const DPL::OptionalString imagePath)
+bool SplashScreenSupport::createSplashScreen(
+    const DPL::OptionalString imagePath)
 {
     LogDebug("initializing splash screen");
 
index 9a4d548..b32aa09 100644 (file)
@@ -27,7 +27,6 @@
 #include <Evas.h>
 #include <memory>
 
-
 class SplashScreenSupport
 {
   public:
@@ -37,6 +36,7 @@ class SplashScreenSupport
     bool createSplashScreen(const DPL::OptionalString imagePath);
     void startSplashScreen();
     void stopSplashScreen();
+
   private:
     void setSplashImagePath(const char * image_path);
 
old mode 100755 (executable)
new mode 100644 (file)
index d021321..dd64049
@@ -32,6 +32,8 @@ char const* const ELM_STATE_SHOW_CONTENT = "elm,state,show,content";
 char const* const ELM_SWALLOW_CONTENT = "elm.swallow.content";
 char const* const ELM_SWALLOW_BACKWARD = "elm.swallow.backward";
 
+const char *ELM_EVENT_PROFILE_CHANGED = "profile,changed";
+
 char const* const ELM = "elm";
 char const* const LAYOUT = "layout";
 char const* const APPLICATION = "application";
@@ -39,7 +41,7 @@ char const* const INDICATOR = "indicator";
 char const* const NOINDICATOR = "noindicator";
 char const* const INTERNAL_LAYOUT = "internal_layout";
 char const* const FLOATBACKWARD_BUTTON_STYLE = "wrt/backward";
-
+const std::string DESKTOP_PROFILE("desktop");
 } // anonymous namespace
 
 WindowData::WindowData(unsigned long pid, bool manualInit) :
@@ -48,8 +50,7 @@ WindowData::WindowData(unsigned long pid, bool manualInit) :
 {
     m_win = createWindow(pid);
 
-    if (!manualInit)
-    {
+    if (!manualInit) {
         init();
     }
 }
@@ -89,7 +90,7 @@ void WindowData::unsetEvasObjectForLayout()
 
 void WindowData::toggleIndicator(bool fullscreen)
 {
-    LogDebug("fullscreen=" << (fullscreen?"true":"false"));
+    LogDebug("fullscreen=" << (fullscreen ? "true" : "false"));
 
     if (!fullscreen) {
         elm_win_indicator_mode_set(m_win, ELM_WIN_INDICATOR_SHOW);
@@ -99,8 +100,8 @@ void WindowData::toggleIndicator(bool fullscreen)
 }
 
 void WindowData::setViewMode(
-        bool fullscreen,
-        bool backbutton)
+    bool fullscreen,
+    bool backbutton)
 {
     LogDebug("setViewMode");
     LogDebug("fullscreen: " << fullscreen);
@@ -113,7 +114,6 @@ void WindowData::setViewMode(
     if (backbutton) {
         createFloatBackButton();
     }
-
 }
 
 void WindowData::createFloatBackButton()
@@ -141,6 +141,10 @@ Evas_Object* WindowData::createWindow(unsigned long pid)
     ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
     evas_object_resize(window, w, h);
 
+    evas_object_smart_callback_add(window,
+                                   ELM_EVENT_PROFILE_CHANGED,
+                                   winProfileChangedCallback,
+                                   this);
     return window;
 }
 
@@ -150,7 +154,7 @@ Evas_Object* WindowData::createConformant(Evas_Object* parent)
     Evas_Object* conformant = elm_conformant_add(parent);
 
     evas_object_size_hint_weight_set(
-            conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+        conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
     evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
     elm_win_resize_object_add(parent, conformant);
     return conformant;
@@ -165,15 +169,15 @@ Evas_Object* WindowData::createPlatformLayout(Evas_Object* parent)
     ADD_PROFILING_POINT("elm_layout_theme_set", "stop");
 
     evas_object_size_hint_align_set(platform_layout,
-            EVAS_HINT_FILL,
-            EVAS_HINT_FILL);
+                                    EVAS_HINT_FILL,
+                                    EVAS_HINT_FILL);
     evas_object_size_hint_weight_set(platform_layout,
-            EVAS_HINT_EXPAND,
-            EVAS_HINT_EXPAND);
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
 
     elm_object_content_set(parent, platform_layout);
     edje_object_signal_emit(
-            elm_layout_edje_get(platform_layout), ELM_STATE_SHOW_CONTENT, ELM);
+        elm_layout_edje_get(platform_layout), ELM_STATE_SHOW_CONTENT, ELM);
     return platform_layout;
 }
 
@@ -183,11 +187,11 @@ Evas_Object* WindowData::createNavigationBar(Evas_Object* parent)
     Evas_Object* navigation = elm_naviframe_add(parent);
 
     evas_object_size_hint_align_set(navigation,
-            EVAS_HINT_FILL,
-            EVAS_HINT_FILL);
+                                    EVAS_HINT_FILL,
+                                    EVAS_HINT_FILL);
     evas_object_size_hint_weight_set(navigation,
-            EVAS_HINT_EXPAND,
-            EVAS_HINT_EXPAND);
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
     elm_object_part_content_set(parent, ELM_SWALLOW_CONTENT, navigation);
     //elm_object_content_set(parent, navigation);
     return navigation;
@@ -199,82 +203,93 @@ Evas_Object* WindowData::createUserLayout(Evas_Object* parent)
     Evas_Object* layout = elm_layout_add(parent);
     elm_layout_file_set(layout, DAEMON_EDJ_PATH, "client");
     evas_object_size_hint_weight_set(
-            layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+        layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
     evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
 
     ADD_PROFILING_POINT("elm_naviframe_item_push", "start");
     Elm_Object_Item* naviIt = elm_naviframe_item_push(
-        /* Evas_Object *obj */
-        parent,
-        /* const char *title_label  */
-        "",
-        /* Evas_Object *prev_btn */
-        NULL,
-        /* Evas_Object *next_btn */
-        NULL,
-        /* Evas_Object *content */
-        layout,
-        /* const char *item_style */
-        NULL);
+            /* Evas_Object *obj */
+            parent,
+            /* const char *title_label  */
+            "",
+            /* Evas_Object *prev_btn */
+            NULL,
+            /* Evas_Object *next_btn */
+            NULL,
+            /* Evas_Object *content */
+            layout,
+            /* const char *item_style */
+            NULL);
+    ADD_PROFILING_POINT("elm_naviframe_item_push", "stop");
 
     elm_naviframe_item_title_visible_set(naviIt, EINA_FALSE);
 
     return layout;
 }
 
+void WindowData::setDesktopIcon()
+{
+    // set window icon
+    Evas_Object *icon = evas_object_image_add(evas_object_evas_get(m_win));
+    evas_object_image_file_set(icon,
+                               "/opt/share/icons/default/small/tizenScmgz.png",
+                               NULL);
+    elm_win_icon_object_set(m_win, icon);
+}
+
 void WindowData::addNaviBackButtonCallback(
-        const char* event,
-        CallbackType callback,
-        const void* data)
+    const char* event,
+    CallbackType callback,
+    const void* data)
 {
     Assert(m_naviBackButton != NULL && "m_naviBackButton is null");
     evas_object_smart_callback_add(m_naviBackButton, event, callback, data);
 }
 
 void* WindowData::delNaviBackButtonCallback(
-        const char* event,
-        CallbackType callBack)
+    const char* event,
+    CallbackType callBack)
 {
     Assert(m_naviBackButton != NULL && "m_naviBackButton is null");
     return evas_object_smart_callback_del(m_naviBackButton, event, callBack);
 }
 
 void WindowData::addFloatBackButtonCallback(
-        const char* event,
-        CallbackType callback,
-        const void* data)
+    const char* event,
+    CallbackType callback,
+    const void* data)
 {
     Assert(m_floatBackButton != NULL && "m_floatBackButton is null");
     evas_object_smart_callback_add(m_floatBackButton, event, callback, data);
 }
 
 void* WindowData::delFloatBackButtonCallback(
-        const char* event,
-        CallbackType callBack)
+    const char* event,
+    CallbackType callBack)
 {
     Assert(m_floatBackButton != NULL && "m_floatBackButton is null");
     return evas_object_smart_callback_del(m_floatBackButton, event, callBack);
 }
 
 void WindowData::userlayoutCallbackAdd(
-        const Evas_Callback_Type event,
-        EvasCallbackType callback,
-        const void* data)
+    const Evas_Callback_Type event,
+    EvasCallbackType callback,
+    const void* data)
 {
     Assert(m_user_layout != NULL && "m_user_layout is null");
     evas_object_event_callback_add(m_user_layout, event, callback, data);
 }
 
 void* WindowData::userlayoutCallbackDel(
-        const Evas_Callback_Type event,
-        EvasCallbackType callBack)
+    const Evas_Callback_Type event,
+    EvasCallbackType callBack)
 {
     Assert(m_user_layout != NULL && "m_user_layout is null");
     return evas_object_event_callback_del(m_user_layout, event, callBack);
 }
 
 void WindowData::emitSignalForUserLayout(
-        const char* emission, const char* source)
+    const char* emission, const char* source)
 {
     LogInfo("emitSignalForUserLayout called");
     Assert(m_user_layout != NULL && "m_user_layout is null");
@@ -282,7 +297,7 @@ void WindowData::emitSignalForUserLayout(
     Assert(source != NULL && "source is null");
 
     edje_object_signal_emit(
-            elm_layout_edje_get(m_user_layout), emission, source);
+        elm_layout_edje_get(m_user_layout), emission, source);
 }
 
 void WindowData::toggleFullscreen(bool fullscreen)
@@ -298,8 +313,27 @@ void WindowData::toggleFullscreen(bool fullscreen)
         return;
     }
 
-    if (!m_fullscreen) //If ViewMode is not fullscreen, toggle indicator
+    if (!m_fullscreen) //If ViewMode is not fullscreen, toggle indicator
         toggleIndicator(fullscreen);
+    }
 
     alreadyFullscreen = !alreadyFullscreen;
 }
+
+void WindowData::winProfileChangedCallback(void *data,
+                                           Evas_Object* /*obj*/,
+                                           void* /*eventInfo*/)
+{
+    LogDebug("winProfileChangedCallback");
+    if (data == NULL) {
+        return;
+    }
+    WindowData* This = static_cast<WindowData *>(data);
+    const char *profile = elm_config_profile_get();
+
+    if (DESKTOP_PROFILE == profile) {
+        elm_win_indicator_mode_set(This->m_win, ELM_WIN_INDICATOR_HIDE);
+        This->setDesktopIcon();
+    }
+}
+
old mode 100755 (executable)
new mode 100644 (file)
index 64c827b..8c656e9
@@ -44,9 +44,9 @@ class WindowData : private DPL::Noncopyable
 {
   private:
     typedef void (*CallbackType)(
-            void* data, Evas_Object* obj, void* event_info);
+        void* data, Evas_Object* obj, void* event_info);
     typedef void (*EvasCallbackType)(
-            void* data, Evas* evas, Evas_Object* obj, void* event_info);
+        void* data, Evas* evas, Evas_Object* obj, void* event_info);
 
     struct EventWithFunction
     {
@@ -56,8 +56,7 @@ class WindowData : private DPL::Noncopyable
                           const char * a_eventName) :
             function(a_function),
             eventName(a_eventName)
-        {
-        }
+        {}
     };
     typedef std::vector<EventWithFunction> EventWithFunctionVector;
 
@@ -65,42 +64,45 @@ class WindowData : private DPL::Noncopyable
     Evas_Object* m_win;
     Evas_Object* m_user_layout;
 
-    explicit WindowData(unsigned long pid, bool manualInit=false);
+    explicit WindowData(unsigned long pid, bool manualInit = false);
     virtual ~WindowData();
 
     void init();
     void setEvasObjectForLayout(Evas_Object* evas_object);
     void unsetEvasObjectForLayout();
     void addNaviBackButtonCallback(
-            const char* event,
-            CallbackType callback,
-            const void* data);
+        const char* event,
+        CallbackType callback,
+        const void* data);
     void* delNaviBackButtonCallback(
-            const char* event,
-            CallbackType callBack);
+        const char* event,
+        CallbackType callBack);
     void addFloatBackButtonCallback(
-            const char* event,
-            CallbackType callback,
-            const void* data);
+        const char* event,
+        CallbackType callback,
+        const void* data);
     void* delFloatBackButtonCallback(
-            const char* event,
-            CallbackType callBack);
+        const char* event,
+        CallbackType callBack);
     void userlayoutCallbackAdd(
-            const Evas_Callback_Type event,
-            EvasCallbackType callback,
-            const void* data);
+        const Evas_Callback_Type event,
+        EvasCallbackType callback,
+        const void* data);
     void* userlayoutCallbackDel(
-            const Evas_Callback_Type event,
-            EvasCallbackType callback);
+        const Evas_Callback_Type event,
+        EvasCallbackType callback);
     void emitSignalForUserLayout(
-            const char* emission,
-            const char* source);
+        const char* emission,
+        const char* source);
 
     void setViewMode(
-            bool fullscreen,
-            bool backbutton);
+        bool fullscreen,
+        bool backbutton);
 
     void toggleFullscreen(bool fullscreen);
+    static void winProfileChangedCallback(void *data,
+                                          Evas_Object * obj,
+                                          void *event_info);
 
   protected:
     Evas_Object* m_conformant;
@@ -119,6 +121,7 @@ class WindowData : private DPL::Noncopyable
     void alignProgressPosition();
     void toggleIndicator(bool fullscreen);
     void createFloatBackButton();
+    void setDesktopIcon();
 };
 
 #endif /* WINDOW_INITIALIZE_H_ */
old mode 100755 (executable)
new mode 100644 (file)
index e69a1f3..3ea7ea7
@@ -15,6 +15,7 @@
  */
 #include "wrt-client.h"
 #include <appcore-efl.h>
+#include <appcore-common.h>
 #include <cstdlib>
 #include <cstdio>
 #include <string>
@@ -28,6 +29,7 @@
 #include <EWebKit2.h>
 #include <dpl/localization/w3c_file_localization.h>
 #include <dpl/localization/LanguageTagsProvider.h>
+#include "webkit/bundles/plugin_module_support.h"
 
 //W3C PACKAGING enviroment variable name
 #define W3C_DEBUG_ENV_VARIABLE "DEBUG_LOAD_FINISH"
@@ -72,7 +74,6 @@ void WrtClient::OnStop()
     LogInfo("Stopping Dummy Client");
 }
 
-
 void WrtClient::OnCreate()
 {
     LogInfo("On Create");
@@ -80,7 +81,6 @@ void WrtClient::OnCreate()
     ewk_init();
 }
 
-
 void WrtClient::OnResume()
 {
     if (m_widgetState != WidgetState_Suspended) {
@@ -91,11 +91,8 @@ void WrtClient::OnResume()
     m_widgetState = WidgetState_Running;
 }
 
-
 void WrtClient::OnPause()
 {
-    LogDebug("On pause");
-
     if (m_widgetState != WidgetState_Running) {
         LogWarning("Widget is not running to be suspended");
         return;
@@ -124,15 +121,18 @@ void WrtClient::OnReset(bundle *b)
         m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
         m_widgetState = WidgetState_Running;
     } else {
-        if (true == checkArgument())
-        {
+        if (true == checkArgument()) {
             setStep();
-        }
-        else
-        {
+        } else {
             showHelpAndQuit();
         }
     }
+
+    // low memory callback set
+    appcore_set_event_callback(
+            APPCORE_EVENT_LOW_MEMORY,
+            WrtClient::appcoreLowMemoryCallback,
+            this);
 }
 
 void WrtClient::OnTerminate()
@@ -161,7 +161,7 @@ bool WrtClient::checkArgument()
 {
     std::string tizenId = getTizenIdFromArgument(m_argc, m_argv);
 
-    if(tizenId.empty()){
+    if (tizenId.empty()) {
         // Just show help
         return false;
     } else {
@@ -190,7 +190,8 @@ std::string WrtClient::getTizenIdFromArgument(int argc, char **argv)
         if (arg == "-h" || arg == "--help") {
             return "";
         } else if (arg == "-l" || arg == "--launch" ||
-                arg == "-t" || arg == "--tizen") {
+                   arg == "-t" || arg == "--tizen")
+        {
             if (argc != 3) {
                 return "";
             }
@@ -208,8 +209,6 @@ std::string WrtClient::getTizenIdFromArgument(int argc, char **argv)
 
         return arg;
     }
-
-    return "";
 }
 
 void WrtClient::setStep()
@@ -263,9 +262,9 @@ bool WrtClient::checkDebugMode(SDKDebugData* debugData)
         // In WAC widget, only test widgets can use web inspector.
         // In TIZEN widget,
         // every launched widgets as debug mode can use it.
-        if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_WAC20)
-        {
-            bool developerMode = WRT::CoreModuleSingleton::Instance().developerMode();
+        if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_WAC20) {
+            bool developerMode =
+                WRT::CoreModuleSingleton::Instance().developerMode();
             //This code will be activated
             //after WAC test certificate is used by SDK
             //bool isTestWidget = view->m_widgetModel->IsTestWidget.Get();
@@ -292,7 +291,7 @@ void WrtClient::OnEventReceived(const NextStepEvent& /*event*/)
 void WrtClient::initStep()
 {
     LogDebug("");
-    if (WRT::CoreModuleSingleton::Instance().Init(s_ewk_context)) {
+    if (WRT::CoreModuleSingleton::Instance().Init()) {
         m_initialized = true;
     } else {
         m_returnStatus = ReturnStatus::Failed;
@@ -303,7 +302,7 @@ void WrtClient::initStep()
     // other type events. To give a chance of execute to other events,
     // ecore_timer_add was used.
     DPL::Event::ControllerEventHandler<NextStepEvent>::PostTimedEvent(
-            NextStepEvent(),0.001);
+        NextStepEvent(), 0.001);
 }
 
 bool WrtClient::checkWACTestCertififedWidget()
@@ -327,12 +326,11 @@ bool WrtClient::checkWACTestCertififedWidget()
     LogDebug("Is developer Mode: " << developerMode);
 
     if (developerWidget) {
-        if(!developerMode)
-        {
+        if (!developerMode) {
             LogError("WAC test certified developer widget is needed for " <<
-                    "developer mode");
+                     "developer mode");
             return false;
-        }else{
+        } else {
             //TODO: WR-4660 (show popup about developer widget
             //      during launch
             LogInfo("POPUP: THIS IS TEST WIDGET!");
@@ -354,8 +352,7 @@ void WrtClient::loadFinishCallback(Evas_Object* webview)
     // Start inspector server, if current mode is debugger mode.
     // In the WK2 case, ewk_view_inspector_server_start should
     // be called after WebProcess is created.
-    if (checkDebugMode(debug))
-    {
+    if (checkDebugMode(debug)) {
         debug->portnum =
             ewk_view_inspector_server_start(m_widget->GetCurrentWebview(), 0);
         if (debug->portnum == 0) {
@@ -370,10 +367,9 @@ void WrtClient::loadFinishCallback(Evas_Object* webview)
 
     //w3c packaging test debug (message on 4>)
     const char * makeScreen = getenv(W3C_DEBUG_ENV_VARIABLE);
-    if(makeScreen != NULL && strcmp(makeScreen, "1") == 0)
-    {
+    if (makeScreen != NULL && strcmp(makeScreen, "1") == 0) {
         FILE* doutput = fdopen(4, "w");
-        fprintf(doutput,"didFinishLoadForFrameCallback: ready\n");
+        fprintf(doutput, "didFinishLoadForFrameCallback: ready\n");
         fclose(doutput);
     }
 
@@ -392,19 +388,18 @@ void WrtClient::loadFinishCallback(Evas_Object* webview)
         m_returnStatus = ReturnStatus::Failed;
         //shutdownStep
         DPL::Event::ControllerEventHandler<NextStepEvent>::
-                PostEvent(NextStepEvent());
+            PostEvent(NextStepEvent());
     }
 
-    if(debug->debugMode)
-    {
+    if (debug->debugMode) {
         LogDebug("Send RT signal to wrt-launcher(pid: " << m_sdkLauncherPid);
         union sigval sv;
         /* send real time signal with result to wrt-launcher */
-        if(webview) {
+        if (webview) {
             LogDebug("userData->portnum : " << debug->portnum);
             sv.sival_int = debug->portnum;
         } else {
-           sv.sival_int = -1;
+            sv.sival_int = -1;
         }
         sigqueue(m_sdkLauncherPid, SIGRTMIN, sv);
     }
@@ -426,7 +421,7 @@ void WrtClient::webkitExitCallback()
     LogDebug("window close called, terminating app");
     SwitchToStep(&WrtClient::shutdownStep);
     DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
-            NextStepEvent());
+        NextStepEvent());
 }
 
 void WrtClient::webCrashCallback()
@@ -434,10 +429,9 @@ void WrtClient::webCrashCallback()
     LogError("webProcess crashed");
     SwitchToStep(&WrtClient::shutdownStep);
     DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
-            NextStepEvent());
+        NextStepEvent());
 }
 
-
 void WrtClient::launchStep()
 {
     ADD_PROFILING_POINT("launchStep", "start");
@@ -445,35 +439,35 @@ void WrtClient::launchStep()
 
     ADD_PROFILING_POINT("getRunnableWidgetObject", "start");
     m_widget = WRT::CoreModuleSingleton::Instance()
-                    .getRunnableWidgetObject(m_tizenId);
+            .getRunnableWidgetObject(m_tizenId);
     ADD_PROFILING_POINT("getRunnableWidgetObject", "stop");
 
     if (!m_widget) {
         LogError("RunnableWidgetObject is NULL, stop launchStep");
         DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
-                    NextStepEvent());
+            NextStepEvent());
         return;
     }
 
     if (m_widgetState == WidgetState_Running) {
         LogWarning("Widget already running, stop launchStep");
         DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
-                    NextStepEvent());
+            NextStepEvent());
         return;
     }
 
     if (m_widgetState == WidgetState_Authorizing) {
         LogWarning("Widget already authorizing, stop launchStep");
         DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
-                    NextStepEvent());
+            NextStepEvent());
         return;
     }
 
     m_dao.reset(new WrtDB::WidgetDAOReadOnly(DPL::FromASCIIString(m_tizenId)));
     DPL::Optional<DPL::String> defloc = m_dao->getDefaultlocale();
-    if(!defloc.IsNull())
-    {
-        LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc);
+    if (!defloc.IsNull()) {
+        LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
+            *defloc);
     }
 
     // For localizationsetting not changed on widget running
@@ -481,32 +475,38 @@ void WrtClient::launchStep()
     //        languageChangedCallback, this);
 
     ADD_PROFILING_POINT("CreateWindow", "start");
-    m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid())));
+    m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid()),
+                                      true));
     ADD_PROFILING_POINT("CreateWindow", "stop");
 
     WRT::UserDelegatesPtr cbs(new WRT::UserDelegates);
     ADD_PROFILING_POINT("Create splash screen", "start");
     m_splashScreen.reset(
-            new SplashScreenSupport(m_windowData->m_win));
+        new SplashScreenSupport(m_windowData->m_win));
     if (m_splashScreen->createSplashScreen(m_dao->getSplashImgSrc())) {
         m_splashScreen->startSplashScreen();
-        cbs->progressFinish = DPL::MakeDelegate(this, &WrtClient::progressFinishCallback);
+        cbs->progressFinish = DPL::MakeDelegate(
+                this,
+                &WrtClient::
+                    progressFinishCallback);
     }
     ADD_PROFILING_POINT("Create splash screen", "stop");
     DPL::OptionalString startUrl = W3CFileLocalization::getStartFile(m_dao);
     if (!m_widget->PrepareView(DPL::ToUTF8String(*startUrl),
-            m_windowData->m_win))
+            m_windowData->m_win, s_ewk_context))
     {
         DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
-                    NextStepEvent());
+            NextStepEvent());
         return;
-     }
+    }
     //you can't show window with splash screen before PrepareView
     //ewk_view_add_with_context() in viewLogic breaks window
 
+    m_windowData->init();
+
     WrtDB::WidgetLocalizedInfo localizedInfo =
         W3CFileLocalization::getLocalizedInfo(m_dao);
-    std:: string name = "";
+    std::string name = "";
     if (!(localizedInfo.name.IsNull())) {
         name = DPL::ToUTF8String(*(localizedInfo.name));
     }
@@ -515,8 +515,7 @@ void WrtClient::launchStep()
     initializeWindowModes();
     connectElmCallback();
 
-    if (!checkWACTestCertififedWidget())
-    {
+    if (!checkWACTestCertififedWidget()) {
         LogWarning("WAC Certificate failed, stop launchStep");
         return;
     }
@@ -525,7 +524,7 @@ void WrtClient::launchStep()
     if (!m_widget->CheckBeforeLaunch()) {
         LogError("CheckBeforeLaunch failed, stop launchStep");
         DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
-                    NextStepEvent());
+            NextStepEvent());
         return;
     }
     LogInfo("Widget launch accepted. Entering running state");
@@ -536,7 +535,8 @@ void WrtClient::launchStep()
     cbs->bufferUnset = DPL::MakeDelegate(this, &WrtClient::unsetLayout);
     cbs->webkitExit = DPL::MakeDelegate(this, &WrtClient::webkitExitCallback);
     cbs->webCrash = DPL::MakeDelegate(this, &WrtClient::webCrashCallback);
-    cbs->toggleFullscreen = DPL::MakeDelegate(m_windowData.get(), &WindowData::toggleFullscreen);
+    cbs->toggleFullscreen = DPL::MakeDelegate(
+            m_windowData.get(), &WindowData::toggleFullscreen);
 
     m_widget->SetUserDelegates(cbs);
     m_widget->Show();
@@ -551,13 +551,13 @@ void WrtClient::initializeWindowModes()
     auto windowModes = m_dao->getWindowModes();
     bool fullscreen = false;
     bool backbutton = false;
-     if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
-         WidgetSettings widgetSettings;
-         m_dao->getWidgetSettings(widgetSettings);
-         WidgetSettingList settings(widgetSettings);
+    if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
+        WidgetSettings widgetSettings;
+        m_dao->getWidgetSettings(widgetSettings);
+        WidgetSettingList settings(widgetSettings);
         backbutton =
             (settings.getBackButtonPresence() == BackButton_Enable);
-     }
+    }
 
     FOREACH(it, windowModes)
     {
@@ -571,12 +571,12 @@ void WrtClient::initializeWindowModes()
     }
 
     m_windowData->setViewMode(fullscreen,
-            backbutton);
+                              backbutton);
 }
 
 void WrtClient::backButtonCallback(void* data,
-                                     Evas_Object * /*obj*/,
-                                     void * /*event_info*/)
+                                   Evas_Object * /*obj*/,
+                                   void * /*event_info*/)
 {
     LogInfo("BackButtonCallback");
     Assert(data);
@@ -586,6 +586,17 @@ void WrtClient::backButtonCallback(void* data,
     This->m_widget->Backward();
 }
 
+int WrtClient::appcoreLowMemoryCallback(void* /*data*/)
+{
+    LogInfo("appcoreLowMemoryCallback");
+    //WrtClient* This = static_cast<WrtClient*>(data);
+
+    // TODO call RunnableWidgetObject API regarding low memory
+    // The API should be implemented
+
+    return 0;
+}
+
 void WrtClient::connectElmCallback()
 {
     Assert(m_windowData);
@@ -596,52 +607,59 @@ void WrtClient::connectElmCallback()
         WidgetSettingList settings(widgetSettings);
         if (settings.getBackButtonPresence() == BackButton_Enable) {
             m_windowData->addFloatBackButtonCallback(
-            "clicked",
-            &WrtClient::backButtonCallback,
-            this);
+                "clicked",
+                &WrtClient::backButtonCallback,
+                this);
         }
 
         WidgetSettingScreenLock rotationValue = settings.getRotationValue();
         if (rotationValue == Screen_Portrait) {
             elm_win_rotation_with_resize_set(m_windowData->m_win, 0);
+            ewk_view_orientation_send(m_widget->GetCurrentWebview(), 0);
         } else if (rotationValue == Screen_Landscape) {
             elm_win_rotation_with_resize_set(m_windowData->m_win, 270);
+            ewk_view_orientation_send(m_widget->GetCurrentWebview(), 90);
         } else {
             elm_win_rotation_with_resize_set(m_windowData->m_win, 0);
+            ewk_view_orientation_send(m_widget->GetCurrentWebview(), 0);
         }
     }
 }
 
-void WrtClient::setLayout(Evas_Object* newBuffer) {
+void WrtClient::setLayout(Evas_Object* newBuffer)
+{
     LogDebug("add new webkit buffer to window");
     Assert(newBuffer);
 
-    elm_object_part_content_set(m_windowData->m_user_layout, ELM_SWALLOW_CONTENT, newBuffer);
+    elm_object_part_content_set(m_windowData->m_user_layout,
+                                ELM_SWALLOW_CONTENT,
+                                newBuffer);
 
     evas_object_show(newBuffer);
 }
 
-void WrtClient::unsetLayout(Evas_Object* currentBuffer) {
+void WrtClient::unsetLayout(Evas_Object* currentBuffer)
+{
     LogDebug("remove current webkit buffer from window");
     Assert(currentBuffer);
     evas_object_hide(currentBuffer);
 
-    elm_object_part_content_unset(m_windowData->m_user_layout, ELM_SWALLOW_CONTENT);
+    elm_object_part_content_unset(m_windowData->m_user_layout,
+                                  ELM_SWALLOW_CONTENT);
 }
 
 void WrtClient::shutdownStep()
 {
     LogDebug("Closing Wrt connection ...");
 
-    if (m_widget && m_widgetState)
-    {
+    if (m_widget && m_widgetState) {
         m_widgetState = WidgetState_Stopped;
         m_widget->Hide();
         m_widget.reset();
+        ewk_context_delete(s_ewk_context);
         WRT::CoreModuleSingleton::Instance().Terminate();
     }
-    if (m_initialized)
-    {
+    if (m_initialized) {
         m_initialized = false;
     }
     m_windowData.reset();
@@ -651,23 +669,26 @@ void WrtClient::shutdownStep()
 int WrtClient::languageChangedCallback(void *data)
 {
     LogDebug("Language Changed");
-    if(!data)
+    if (!data) {
         return 0;
+    }
     WrtClient* wrtClient = static_cast<WrtClient*>(data);
-    if(!(wrtClient->m_dao))
+    if (!(wrtClient->m_dao)) {
         return 0;
+    }
 
     // reset function fetches system locales and recreates language tags
     LanguageTagsProviderSingleton::Instance().resetLanguageTags();
     // widget default locales are added to language tags below
     DPL::OptionalString defloc = wrtClient->m_dao->getDefaultlocale();
-    if(!defloc.IsNull())
-    {
-        LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc);
+    if (!defloc.IsNull()) {
+        LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
+            *defloc);
     }
 
     if (wrtClient->m_launched &&
-            wrtClient->m_widgetState != WidgetState_Stopped) {
+        wrtClient->m_widgetState != WidgetState_Stopped)
+    {
         wrtClient->m_widget->ReloadStartPage();
     }
     return 0;
@@ -692,10 +713,9 @@ int main(int argc,
         // set evas backend type
         if (!getenv("ELM_ENGINE")) {
             if (!setenv("ELM_ENGINE", "gl", 1)) {
-                    LogDebug("Enable backend");
+                LogDebug("Enable backend");
             }
-        }
-        else {
+        } else {
             LogDebug("ELM_ENGINE : " << getenv("ELM_ENGINE"));
         }
 
@@ -709,15 +729,18 @@ int main(int argc,
         // This code is to fork a web process without exec.
         std::string tizenId = WrtClient::getTizenIdFromArgument(argc, argv);
 
-        if (!tizenId.empty())
-        {
+        if (!tizenId.empty()) {
             LogDebug("Launching by fork mode");
             // Language env setup
             appcore_set_i18n("wrt-client", NULL);
             ewk_init();
             ewk_set_arguments(argc, argv);
             setenv("WRT_LAUNCHING_PERFORMANCE", "1", 1);
-            s_ewk_context = ewk_context_new_with_injected_bundle_path(BUNDLE_PATH);
+            s_ewk_context = ewk_context_new_with_injected_bundle_path(
+                    BUNDLE_PATH);
+
+            // plugin init
+            PluginModuleSupport::init(s_ewk_context, tizenId);
         }
 
         // Output on stdout will be flushed after every newline character,
@@ -728,7 +751,6 @@ int main(int argc,
         // the output may not be flushed).
         setlinebuf(stdout);
 
-
         WrtClient app(argc, argv);
 
         ADD_PROFILING_POINT("Before appExec", "point");
old mode 100755 (executable)
new mode 100644 (file)
index 078dbcc..36a25f3
@@ -33,9 +33,9 @@
 DECLARE_GENERIC_EVENT_0(NextStepEvent)
 
 class WrtClient :
-        public DPL::Application,
-        private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
-        public DPL::TaskDecl<WrtClient>
+    public DPL::Application,
+    private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
+    public DPL::TaskDecl<WrtClient>
 {
   public:
     WrtClient(int argc,
@@ -82,6 +82,8 @@ class WrtClient :
     static void backButtonCallback(void* data,
                                    Evas_Object* obj,
                                    void* event_info);
+    // Low Memory Callback
+    static int appcoreLowMemoryCallback(void* data);
 
     // launching steps
     void initStep();
@@ -102,7 +104,6 @@ class WrtClient :
     bool m_initialized;
     int m_sdkLauncherPid;
     bool m_debugMode;
-    bundle *m_bundle;
     unsigned short m_debuggerPort;
     ReturnStatus::Type m_returnStatus;
     WRT::RunnableWidgetObjectPtr m_widget;
index a1c2fa7..16f8d00 100644 (file)
@@ -31,6 +31,7 @@
 #include <dpl/wrt-dao-ro/wrt_db_types.h>
 #include <dpl/wrt-dao-rw/global_dao.h>
 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
 #include <dpl/exception.h>
 
 #define TIMEOUT_DEFAULT     10
@@ -62,12 +63,14 @@ static std::unique_ptr<DBConnection> g_dbConnection;
 typedef struct
 {
     char* guid;           /**< the widget's id
-                           (read from its config.xml during installation)*/
+                           (read from its config.xml during installation)*/
     char* name;         /**< the widget's name
-                           (read from its config.xml during installation)*/
+                         * (read from its config.xml during installation)*/
     char* version;      /**< the widget's varsion
-                           (read from its config.xml during installation)*/
-    char* pkg_name;     /**< the widget's pkg name */
+                         * (read from its config.xml during installation)*/
+    char* pkg_id;       /**< the widget's pkg id */
+
+    char* app_id;
 } widget_info;
 
 static void free_widget_info(widget_info* widget_info)
@@ -76,7 +79,8 @@ static void free_widget_info(widget_info* widget_info)
         delete[] widget_info->guid;
         delete[] widget_info->name;
         delete[] widget_info->version;
-        delete[] widget_info->pkg_name;
+        delete[] widget_info->pkg_id;
+        delete[] widget_info->app_id;
         delete widget_info;
     }
 }
@@ -96,7 +100,7 @@ static bool attachDbConnection()
             g_dbConnection.reset(new DBConnection());
             g_dbConnection->AttachDatabase();
         }
-        Catch (DPL::DB::SqlConnection::Exception::Base) {
+        Catch(DPL::DB::SqlConnection::Exception::Base) {
             LogDebug("Fail to connect DB");
             return FALSE;
         }
@@ -106,15 +110,17 @@ static bool attachDbConnection()
 
 static bool display_widget_info()
 {
-    if(!attachDbConnection()) return FALSE;
+    if (!attachDbConnection()) {
+        return FALSE;
+    }
 
     WidgetDAOReadOnlyList widgetList =
-            WrtDB::WidgetDAOReadOnly::getWidgetList();
+        WrtDB::WidgetDAOReadOnly::getWidgetList();
 
-    printf("%3s %32s %16s %64s %16s\n",
-           "No", "Name", "Version", "GUID", "Package Name");
-    printf("%3s %32s %16s %64s %16s\n",
-           "--", "--", "----", "-------", "----");
+    printf("%3s %32s %16s %64s %16s %24s\n",
+           "No", "Name", "Version", "GUID", "Package ID", "App ID");
+    printf("%3s %32s %16s %64s %16s %24s\n",
+           "--", "--", "----", "-------", "-----", "-----");
 
     int number = 1;
     FOREACH(dao, widgetList) {
@@ -123,7 +129,9 @@ static bool display_widget_info()
 
         WrtDB::WidgetGUID guid = (*dao)->getGUID();
         DPL::Optional<DPL::String> version = (*dao)->getVersion();
-        WrtDB::WidgetPkgName package_name = (*dao)->getPkgName();
+        WrtDB::TizenAppId appid = (*dao)->getTzAppId();
+        WrtDB::TizenPkgId pkgid = (*dao)->getTizenPkgId();
+
 
         /*get WidgetName*/
         DPL::Optional<DPL::String> widget_name;
@@ -153,15 +161,16 @@ static bool display_widget_info()
             info->guid = new_strdup(DPL::ToUTF8String(*guid).c_str());
         }
 
-        info->pkg_name = new_strdup(DPL::ToUTF8String(package_name).c_str());
-
+        info->app_id = new_strdup(DPL::ToUTF8String(appid).c_str());
+        info->pkg_id = new_strdup(DPL::ToUTF8String(pkgid).c_str());
 
-        printf("%3i %32s %16s %64s %16s\n",
+        printf("%3i %32s %16s %64s %16s %24s\n",
                number++,
                !info->name ? "[NULL]" : info->name,
                !info->version ? "[NULL]" : info->version,
                !info->guid ? "[NULL]" : info->guid,
-               !info->pkg_name ? "[NULL]" : info->pkg_name);
+               !info->pkg_id ? "[NULL]" : info->pkg_id,
+               !info->app_id ? "[NULL]" : info->app_id);
 
         free_widget_info(info);
     }
@@ -172,21 +181,22 @@ static bool display_widget_info()
 static void print_help(FILE *stream, int /*exit_code*/)
 {
     fprintf(stream, "Usage : %s [ ... ]\n", program);
-    fprintf(stream,
-            "   -h                       --help              Display this usage information.\n"
-            "   -l                       --list              Display installed widgets list\n"
-            "   -s [GUID]or[PkgName]     --start             Launch widget with package name or GUID\n"
-            "   -k [GUID]or[PkgName]     --kill              Kill widget with package name or GUID\n"
-            "   -r [GUID]or[PkgName]     --is-running        Check whether widget is running by package name or GUID,\n"
-            "                                                If widget is running, 0(zero) will be returned.\n"
-            "   -d                       --debug             Activate debug mode\n"
-            "   -t [second]              --timeout           Set timeout of response from widget in debug mode\n"
-            "   -v [1]or[0]              --developer-mode    Set developermode\n"
-            "   -c [1]or[0]              --compliance-mode   Set compliancemode\n"
-            "   -i [imei]                --fake-imei         Set fakeimei\n"
-            "   -m [meid]                --fake-meid         Set fakemeid\n"
-            "    if you emit this option, 5 seconds is set in debug mode\n"
-            );
+    fprintf(
+        stream,
+        "   -h                       --help              Display this usage information.\n"
+        "   -l                       --list              Display installed widgets list\n"
+        "   -s [GUID]or[PkgName]     --start             Launch widget with package name or GUID\n"
+        "   -k [GUID]or[PkgName]     --kill              Kill widget with package name or GUID\n"
+        "   -r [GUID]or[PkgName]     --is-running        Check whether widget is running by package name or GUID,\n"
+        "                                                If widget is running, 0(zero) will be returned.\n"
+        "   -d                       --debug             Activate debug mode\n"
+        "   -t [second]              --timeout           Set timeout of response from widget in debug mode\n"
+        "   -v [1]or[0]              --developer-mode    Set developermode\n"
+        "   -c [1]or[0]              --compliance-mode   Set compliancemode\n"
+        "   -i [imei]                --fake-imei         Set fakeimei\n"
+        "   -m [meid]                --fake-meid         Set fakemeid\n"
+        "    if you emit this option, 5 seconds is set in debug mode\n"
+        );
 }
 
 static void sighandler(int signo, siginfo_t *si, void *data);
@@ -212,18 +222,18 @@ int main(int argc, char* argv[])
         program = argv[0];
 
         static struct option long_options[] = {
-            {"help", no_argument, 0, 'h'},
-            {"list", no_argument, 0, 'l'},
-            {"start", required_argument, 0, 's'},
-            {"kill", required_argument, 0, 'k'},
-            {"is-running", required_argument, 0, 'r'},
-            {"debug", no_argument, 0, 'd'},
-            {"timeout", required_argument, 0, 't'},
-            {"developer-mode", required_argument, 0, 'v'},
-            {"compliance-mode", required_argument, 0, 'c'},
-            {"fake-imei", required_argument, 0, 'i'},
-            {"fake-meid", required_argument, 0, 'm'},
-            {0, 0, 0, 0}
+            { "help", no_argument, 0, 'h' },
+            { "list", no_argument, 0, 'l' },
+            { "start", required_argument, 0, 's' },
+            { "kill", required_argument, 0, 'k' },
+            { "is-running", required_argument, 0, 'r' },
+            { "debug", no_argument, 0, 'd' },
+            { "timeout", required_argument, 0, 't' },
+            { "developer-mode", required_argument, 0, 'v' },
+            { "compliance-mode", required_argument, 0, 'c' },
+            { "fake-imei", required_argument, 0, 'i' },
+            { "fake-meid", required_argument, 0, 'm' },
+            { 0, 0, 0, 0 }
         };
 
         if (argv[1] == NULL) {
@@ -252,15 +262,16 @@ int main(int argc, char* argv[])
 
             switch (next_opt) {
             case 'h':
-                if(!dispHelp){
+                if (!dispHelp) {
                     print_help(stdout, 0);
                     dispHelp = true;
-                 }
+                }
                 break;
 
             case 'l':
-                if(dispList)
+                if (dispList) {
                     break;
+                }
                 if (!display_widget_info()) {
                     printf("Fail to display the list of installed widgets");
                     return -1;
@@ -277,7 +288,7 @@ int main(int argc, char* argv[])
 
             case 't':
                 timeout = atoi(optarg);
-                if (timeout < 0 ) {
+                if (timeout < 0) {
                     timeout = TIMEOUT_DEFAULT;
                 }
                 break;
@@ -315,7 +326,9 @@ int main(int argc, char* argv[])
 
             case 'v':
                 strncpy(temp_arg, optarg, strlen(optarg));
-                if(!attachDbConnection()) return FALSE;
+                if (!attachDbConnection()) {
+                    return FALSE;
+                }
                 if (!strcmp("1", temp_arg)) {
                     WrtDB::GlobalDAO::SetDeveloperMode(true);
                 } else {
@@ -324,8 +337,10 @@ int main(int argc, char* argv[])
                 break;
             case 'c':
                 strncpy(temp_arg, optarg, strlen(optarg));
-                if(!attachDbConnection()) return FALSE;
-                if(!strcmp("1", temp_arg)) {
+                if (!attachDbConnection()) {
+                    return FALSE;
+                }
+                if (!strcmp("1", temp_arg)) {
                     WrtDB::GlobalDAO::setComplianceMode(true);
                 } else {
                     WrtDB::GlobalDAO::setComplianceMode(false);
@@ -333,12 +348,16 @@ int main(int argc, char* argv[])
                 break;
             case 'i':
                 strncpy(temp_arg, optarg, strlen(optarg));
-                if(!attachDbConnection()) return FALSE;
+                if (!attachDbConnection()) {
+                    return FALSE;
+                }
                 WrtDB::GlobalDAO::setComplianceFakeImei(temp_arg);
                 break;
             case 'm':
                 strncpy(temp_arg, optarg, strlen(optarg));
-                if(!attachDbConnection()) return FALSE;
+                if (!attachDbConnection()) {
+                    return FALSE;
+                }
                 WrtDB::GlobalDAO::setComplianceFakeMeid(temp_arg);
                 break;
 
@@ -351,7 +370,7 @@ int main(int argc, char* argv[])
             }
         } while (next_opt != -1);
 
-        if ((op == 's') || (op == 'k') || (op =='r')) {
+        if ((op == 's') || (op == 'k') || (op == 'r')) {
             std::string temp;
 
             if (NULL == g_dbConnection.get()) {
@@ -359,14 +378,17 @@ int main(int argc, char* argv[])
                     g_dbConnection.reset(new DBConnection());
                     g_dbConnection->AttachDatabase();
                 }
-                Catch (DPL::DB::SqlConnection::Exception::Base) {
+                Catch(DPL::DB::SqlConnection::Exception::Base) {
                     LogDebug("Fail to connect DB");
                     return FALSE;
                 }
             }
+            DPL::OptionalString normal_str = DPL::FromUTF8String(temp_arg);
+            WrtDB::NormalizeAndTrimSpaceString(normal_str);
+            std::string normal_arg = DPL::ToUTF8String(*normal_str);
 
             WidgetDAOReadOnlyList widgetList =
-                    WrtDB::WidgetDAOReadOnly::getWidgetList();
+                WrtDB::WidgetDAOReadOnly::getWidgetList();
             FOREACH(dao, widgetList) {
                 WrtDB::WidgetGUID d_guid = (*dao)->getGUID();
                 WrtDB::WidgetPkgName d_pkgname = (*dao)->getPkgName();
@@ -377,7 +399,9 @@ int main(int argc, char* argv[])
                     temp = DPL::ToUTF8String(package_name);
                     break;
                 }
-                if (!strcmp(DPL::ToUTF8String(d_pkgname).c_str(), temp_arg)) {
+                if (!strcmp(DPL::ToUTF8String(d_pkgname).c_str(),
+                            normal_arg.c_str()))
+                {
                     WrtDB::WidgetPkgName package_name = (*dao)->getPkgName();
                     temp = DPL::ToUTF8String(package_name);
                     break;
@@ -421,12 +445,12 @@ int main(int argc, char* argv[])
                 gid_t group_list[1];
                 group_list[0] = LOGGING_DEFAULT_GID;
 
-                if(setgroups(sizeof(group_list), group_list) < 0) {
+                if (setgroups(sizeof(group_list), group_list) < 0) {
                     printf("result: %s\n", "failed");
                     return -1;
                 }
 
-                if(setreuid(WEBAPP_DEFAULT_UID, WEBAPP_DEFAULT_GID) < 0) {
+                if (setreuid(WEBAPP_DEFAULT_UID, WEBAPP_DEFAULT_GID) < 0) {
                     printf("result: %s\n", "failed");
                     return -1;
                 }
@@ -540,6 +564,6 @@ static void sighandler(int signo, siginfo_t *si, void* /*data*/)
     } else {
         printf("Not RT signal : %d\n", signo);
     }
-    exit (0);
+    exit(0);
 }
 
index 25e1760..584db6a 100644 (file)
 
 #include <dlfcn.h>
 #include <glib.h>
-#define PREEXEC_FILE SHARE_PREFIX"/preexec_list.txt"
+#define PREEXEC_FILE SHARE_PREFIX "/preexec_list.txt"
 
 static int preexec_initialized = 0;
 
 GSList *preexec_list = NULL;
 
 typedef struct _preexec_list_t {
-       char *pkg_type;
-       char *so_path;
-       int (*dl_do_pre_exe) (char *, char *);
+    char *pkg_type;
+    char *so_path;
+    int (*dl_do_pre_exe)(char *, char *);
+    void *handle;
 } preexec_list_t;
 
 static void __preexec_list_free()
 {
-       GSList *iter = NULL;
-       preexec_list_t *type_t;
-
-       for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
-               type_t = iter->data;
-               if (type_t) {
-                       if (type_t->pkg_type)
-                               free(type_t->pkg_type);
-                       if (type_t->so_path)
-                               free(type_t->so_path);
-                       free(type_t);
-               }
-       }
-       g_slist_free(preexec_list);
-       return;
+    GSList *iter = NULL;
+    preexec_list_t *type_t;
+
+    for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
+        type_t = iter->data;
+        if (type_t) {
+            if (type_t->pkg_type) {
+                free(type_t->pkg_type);
+            }
+            if (type_t->so_path) {
+                free(type_t->so_path);
+            }
+            if (type_t->handle) {
+                dlclose(type_t->handle);
+            }
+            free(type_t);
+        }
+    }
+    g_slist_free(preexec_list);
+    return;
 }
 
 static inline void __preexec_init(int argc, char **argv)
 {
-       void *handle = NULL;
-       FILE *preexec_file;
-       char *saveptr = NULL;
-       char line[MAX_LOCAL_BUFSZ] = {0, };
-       char *type = NULL;
-       char *sopath = NULL;
-       char *symbol = NULL;
-       int (*func) (char *, char *) = NULL;
-       preexec_list_t *type_t = NULL;
-
-        // warning: unused parameter
-        argc = argc;
-        argv = argv;
-
-       preexec_file = fopen(PREEXEC_FILE, "rt");
-       if (preexec_file == NULL) {
-               _E("no preexec\n");
-               return;
-       }
-
-       _D("preexec start\n");
-
-       while (fgets(line, MAX_LOCAL_BUFSZ, preexec_file) > (char*)0) {
-               /* Parse each line */
-               if (line[0] == '#' || line[0] == '\0')
-                       continue;
-
-               type = strtok_r(line, ":\f\n\r\t\v ", &saveptr);
-               if (type == NULL)
-                       continue;
-               sopath = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
-               if (sopath == NULL)
-                       continue;
-               symbol = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
-               if (symbol == NULL)
-                       continue;
-
-               type_t = (preexec_list_t *) calloc(1, sizeof(preexec_list_t));
-               if (type_t == NULL) {
-                       _E("no available memory\n");
-                       __preexec_list_free();
+    void *handle = NULL;
+    FILE *preexec_file;
+    char *saveptr = NULL;
+    char line[MAX_LOCAL_BUFSZ] = { 0, };
+    char *type = NULL;
+    char *sopath = NULL;
+    char *symbol = NULL;
+    int (*func)(char *, char *) = NULL;
+    preexec_list_t *type_t = NULL;
+
+    // warning: unused parameter
+    argc = argc;
+    argv = argv;
+
+    preexec_file = fopen(PREEXEC_FILE, "rt");
+    if (preexec_file == NULL) {
+        _E("no preexec\n");
+        return;
+    }
+
+    _D("preexec start\n");
+
+    while (fgets(line, MAX_LOCAL_BUFSZ, preexec_file) > (char*)0) {
+        /* Parse each line */
+        if (line[0] == '#' || line[0] == '\0') {
+            continue;
+        }
+
+        type = strtok_r(line, ":\f\n\r\t\v ", &saveptr);
+        if (type == NULL) {
+            continue;
+        }
+        sopath = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
+        if (sopath == NULL) {
+            continue;
+        }
+        symbol = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
+        if (symbol == NULL) {
+            continue;
+        }
+
+        type_t = (preexec_list_t *) calloc(1, sizeof(preexec_list_t));
+        if (type_t == NULL) {
+            _E("no available memory\n");
+            __preexec_list_free();
             fclose(preexec_file);
-                       return;
-               }
-
-               handle = dlopen(sopath, RTLD_NOW);
-               if (handle == NULL) {
-                       free(type_t);
-                       continue;
-               }
-               _D("preexec %s %s# - handle : %x\n", type, sopath, handle);
-
-               func = dlsym(handle, symbol);
-               if (func == NULL) {
-                       _E("failed to get symbol type:%s path:%s\n",
-                          type, sopath);
-                       free(type_t);
-                       dlclose(handle);
-                       handle = NULL;
-                       continue;
-               }
-
-               type_t->pkg_type = strdup(type);
-               if (type_t->pkg_type == NULL) {
-                       _E("no available memory\n");
-                       free(type_t);
-                       __preexec_list_free();
+            return;
+        }
+
+        handle = dlopen(sopath, RTLD_NOW);
+        if (handle == NULL) {
+            free(type_t);
+            continue;
+        }
+        _D("preexec %s %s# - handle : %x\n", type, sopath, handle);
+
+        func = dlsym(handle, symbol);
+        if (func == NULL) {
+            _E("failed to get symbol type:%s path:%s\n",
+               type, sopath);
+            free(type_t);
+            dlclose(handle);
+            handle = NULL;
+            continue;
+        }
+
+        type_t->pkg_type = strdup(type);
+        if (type_t->pkg_type == NULL) {
+            _E("no available memory\n");
+            free(type_t);
+            dlclose(handle);
+            handle = NULL;
+            __preexec_list_free();
             fclose(preexec_file);
-                       return;
-               }
-               type_t->so_path = strdup(sopath);
-               if (type_t->so_path == NULL) {
-                       _E("no available memory\n");
-                       free(type_t->pkg_type);
-                       free(type_t);
-                       __preexec_list_free();
+            return;
+        }
+        type_t->so_path = strdup(sopath);
+        if (type_t->so_path == NULL) {
+            _E("no available memory\n");
+            free(type_t->pkg_type);
+            free(type_t);
+            dlclose(handle);
+            handle = NULL;
+            __preexec_list_free();
             fclose(preexec_file);
-                       return;
-               }
-               type_t->dl_do_pre_exe = func;
+            return;
+        }
+        type_t->handle = handle;
+        type_t->dl_do_pre_exe = func;
 
-               preexec_list = g_slist_append(preexec_list, (void *)type_t);
-       }
+        preexec_list = g_slist_append(preexec_list, (void *)type_t);
+    }
 
-       fclose(preexec_file);
-       preexec_initialized = 1;
+    fclose(preexec_file);
+    preexec_initialized = 1;
 }
 
 static inline void __preexec_run(const char *pkg_type, const char *pkg_name,
-                                const char *app_path)
+                                 const char *app_path)
 {
-       GSList *iter = NULL;
-       preexec_list_t *type_t;
-
-       if (!preexec_initialized)
-               return;
-
-       for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
-               type_t = iter->data;
-               if (type_t) {
-                       if (!strcmp(pkg_type, type_t->pkg_type)) {
-                               if (type_t->dl_do_pre_exe != NULL) {
-                                       type_t->dl_do_pre_exe((char *)pkg_name,
-                                                             (char *)app_path);
-                                       _D("called dl_do_pre_exe() type: %s",
-                                          pkg_type);
-                               } else {
-                                       _E("no symbol for this type: %s",
-                                          pkg_type);
-                               }
-                       }
-               }
-       }
-
+    GSList *iter = NULL;
+    preexec_list_t *type_t;
+
+    if (!preexec_initialized) {
+        return;
+    }
+
+    for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
+        type_t = iter->data;
+        if (type_t) {
+            if (!strcmp(pkg_type, type_t->pkg_type)) {
+                if (type_t->dl_do_pre_exe != NULL) {
+                    type_t->dl_do_pre_exe((char *)pkg_name,
+                                          (char *)app_path);
+                    _D("called dl_do_pre_exe() type: %s",
+                       pkg_type);
+                } else {
+                    _E("no symbol for this type: %s",
+                       pkg_type);
+                }
+            }
+        }
+    }
 }
 
 #else
 
 static inline void __preexec_init(int argc, char **argv)
-{
-}
+{}
 
 static inline void __preexec_run(const char *pkg_type, const char *pkg_name,
-                                const char *app_path)
-{
-}
+                                 const char *app_path)
+{}
 
 #endif
index 0082437..70bc099 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #ifndef __APP_DBUS_H__
 #define __APP_DBUS_H__
 
@@ -24,7 +23,7 @@
 
 #define AUL_DBUS_PATH "/aul/dbus_handler"
 #define AUL_DBUS_SIGNAL_INTERFACE "org.tizen.aul.signal"
-#define AUL_DBUS_APPDEAD_SIGNAL        "app_dead"
-#define AUL_DBUS_APPLAUNCH_SIGNAL      "app_launch"
+#define AUL_DBUS_APPDEAD_SIGNAL "app_dead"
+#define AUL_DBUS_APPLAUNCH_SIGNAL       "app_launch"
 
 #endif
index 044ad8c..4787d87 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #ifndef __APP_PKT_H_
 #define __APP_PKT_H_
 
 #include <linux/un.h>
 
 enum app_cmd {
-       APP_START,
-       APP_OPEN,
-       APP_RESUME,
-       APP_RESUME_BY_PID,
-       APP_TERM_BY_PID,
-       APP_RESULT,
-       APP_START_RES,
-       APP_CANCEL,
-       APP_KILL_BY_PID,
-       APP_ADD_HISTORY,
-       APP_RUNNING_INFO,
-       APP_RUNNING_INFO_RESULT,
-       APP_IS_RUNNING,
-       APP_KEY_EVENT,
-       APP_KEY_RESERVE,
-       APP_KEY_RELEASE,
-       APP_STATUS_UPDATE,
-       APP_RELEASED,
-       APP_RUNNING_LIST_UPDATE
+    APP_START,
+    APP_OPEN,
+    APP_RESUME,
+    APP_RESUME_BY_PID,
+    APP_TERM_BY_PID,
+    APP_RESULT,
+    APP_START_RES,
+    APP_CANCEL,
+    APP_KILL_BY_PID,
+    APP_ADD_HISTORY,
+    APP_RUNNING_INFO,
+    APP_RUNNING_INFO_RESULT,
+    APP_IS_RUNNING,
+    APP_KEY_EVENT,
+    APP_KEY_RESERVE,
+    APP_KEY_RELEASE,
+    APP_STATUS_UPDATE,
+    APP_RELEASED,
+    APP_RUNNING_LIST_UPDATE
 };
 
 #define AUL_SOCK_PREFIX "/tmp/alaunch"
@@ -52,9 +51,9 @@ enum app_cmd {
 #define ELOCALLAUNCH_ID 128
 
 typedef struct _app_pkt_t {
-       int cmd;
-       int len;
-       unsigned char data[1];
+    int cmd;
+    int len;
+    unsigned char data[1];
 } app_pkt_t;
 
 int __create_server_sock(int pid);
index e32a589..813d071 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #ifndef __AUL_UTIL_H_
 #define __AUL_UTIL_H_
 
 #define MAX_PACKAGE_APP_PATH_SIZE 512
 #define MAX_RUNNING_APP_INFO 512
 
-typedef struct _app_status_info_t{
-       char appid[MAX_PACKAGE_STR_SIZE];
-       char app_path[MAX_PACKAGE_APP_PATH_SIZE];
-       int status;
-       int pid;
+typedef struct _app_status_info_t {
+    char appid[MAX_PACKAGE_STR_SIZE];
+    char app_path[MAX_PACKAGE_APP_PATH_SIZE];
+    int status;
+    int pid;
 } app_status_info_t;
 
 struct amdmgr {
-       struct appinfomgr *af;  /* appinfo manager */
-       struct cginfo *cg;  /* cgroup infomation */
+    struct appinfomgr *af;      /* appinfo manager */
+    struct cginfo *cg;      /* cgroup infomation */
 };
 
 int _add_app_status_info_list(char *appid, int pid);
@@ -42,5 +41,3 @@ int _remove_app_status_info_list(int pid);
 
 #endif
 
-
-
index a31bb5f..7f8c8c5 100644 (file)
  *    limitations under the License.
  */
 
-
 #include <ail.h>
 #include <string.h>
 #include "simple_util.h"
 
-#define MAX_PATH_LEN   1024
+#define MAX_PATH_LEN    1024
 
-#define AUL_APP_INFO_FLD_PKG_NAME              "package"
-#define AUL_APP_INFO_FLD_APP_PATH              "exec"
-#define AUL_APP_INFO_FLD_APP_TYPE              "x_slp_packagetype"
-#define AUL_APP_INFO_FLD_WIDTH                 "x_slp_baselayoutwidth"
-#define AUL_APP_INFO_FLD_HEIGHT                        "x_slp_baselayoutheight"
-#define AUL_APP_INFO_FLD_VERTICAL              "x_slp_ishorizontalscale"
-#define AUL_APP_INFO_FLD_MULTIPLE              "x_slp_multiple"
-#define AUL_APP_INFO_FLD_TASK_MANAGE   "x_slp_taskmanage"
-#define AUL_APP_INFO_FLD_MIMETYPE              "mimetype"
-#define AUL_APP_INFO_FLD_SERVICE               "x_slp_service"
+#define AUL_APP_INFO_FLD_PKG_NAME               "package"
+#define AUL_APP_INFO_FLD_APP_PATH               "exec"
+#define AUL_APP_INFO_FLD_APP_TYPE               "x_slp_packagetype"
+#define AUL_APP_INFO_FLD_WIDTH                  "x_slp_baselayoutwidth"
+#define AUL_APP_INFO_FLD_HEIGHT                 "x_slp_baselayoutheight"
+#define AUL_APP_INFO_FLD_VERTICAL               "x_slp_ishorizontalscale"
+#define AUL_APP_INFO_FLD_MULTIPLE               "x_slp_multiple"
+#define AUL_APP_INFO_FLD_TASK_MANAGE    "x_slp_taskmanage"
+#define AUL_APP_INFO_FLD_MIMETYPE               "mimetype"
+#define AUL_APP_INFO_FLD_SERVICE                "x_slp_service"
 
-#define AUL_RETRIEVE_PKG_NAME                  "package = '?'"
-#define AUL_RETRIEVE_APP_PATH                  "exec = '?'"
-#define AUL_RETRIEVE_MIMETYPE                  "mimetype like '?'"
-#define AUL_RETRIEVE_SERVICE                   "x_slp_service like '?'"
+#define AUL_RETRIEVE_PKG_NAME                   "package = '?'"
+#define AUL_RETRIEVE_APP_PATH                   "exec = '?'"
+#define AUL_RETRIEVE_MIMETYPE                   "mimetype like '?'"
+#define AUL_RETRIEVE_SERVICE                    "x_slp_service like '?'"
 
 typedef struct {
-       char *pkg_name;         /* package */
-       char *app_path;         /* exec */
-       char *original_app_path;        /* exec */
-       char *pkg_type;         /* x_slp_packagetype */
-       char *hwacc;            /* hwacceleration */
+    char *pkg_name;             /* package */
+    char *app_path;             /* exec */
+    char *original_app_path;            /* exec */
+    char *pkg_type;             /* x_slp_packagetype */
+    char *hwacc;                /* hwacceleration */
 } app_info_from_db;
 
 static inline char *_get_pkgname(app_info_from_db *menu_info)
 {
-       if (menu_info->pkg_name == NULL)
-               return NULL;
-       return menu_info->pkg_name;
+    if (menu_info->pkg_name == NULL) {
+        return NULL;
+    }
+    return menu_info->pkg_name;
 }
 
 static inline char *_get_app_path(app_info_from_db *menu_info)
 {
-       int i = 0;
-       int path_len = -1;
-
-       if (menu_info->app_path == NULL)
-               return NULL;
-
-       while (menu_info->app_path[i] != 0) {
-               if (menu_info->app_path[i] == ' '
-                   || menu_info->app_path[i] == '\t') {
-                       path_len = i;
-                       break;
-               }
-               i++;
-       }
-
-       if (path_len == 0) {
-               free(menu_info->app_path);
-               menu_info->app_path = NULL;
-       } else if (path_len > 0) {
-               char *tmp_app_path = malloc(sizeof(char) * (path_len + 1));
-               if(tmp_app_path == NULL)
-                       return NULL;
-               snprintf(tmp_app_path, path_len + 1, "%s", menu_info->app_path);
-               free(menu_info->app_path);
-               menu_info->app_path = tmp_app_path;
-       }
-
-       return menu_info->app_path;
+    int i = 0;
+    int path_len = -1;
+
+    if (menu_info->app_path == NULL) {
+        return NULL;
+    }
+
+    while (menu_info->app_path[i] != 0) {
+        if (menu_info->app_path[i] == ' '
+            || menu_info->app_path[i] == '\t')
+        {
+            path_len = i;
+            break;
+        }
+        i++;
+    }
+
+    if (path_len == 0) {
+        free(menu_info->app_path);
+        menu_info->app_path = NULL;
+    } else if (path_len > 0) {
+        char *tmp_app_path = malloc(sizeof(char) * (path_len + 1));
+        if (tmp_app_path == NULL) {
+            return NULL;
+        }
+        snprintf(tmp_app_path, path_len + 1, "%s", menu_info->app_path);
+        free(menu_info->app_path);
+        menu_info->app_path = tmp_app_path;
+    }
+
+    return menu_info->app_path;
 }
 
 static inline char *_get_original_app_path(app_info_from_db *menu_info)
 {
-       if (menu_info->original_app_path == NULL)
-               return NULL;
-       return menu_info->original_app_path;
+    if (menu_info->original_app_path == NULL) {
+        return NULL;
+    }
+    return menu_info->original_app_path;
 }
 
 static inline void _free_app_info_from_db(app_info_from_db *menu_info)
 {
-       if (menu_info != NULL) {
-               if (menu_info->pkg_name != NULL)
-                       free(menu_info->pkg_name);
-               if (menu_info->app_path != NULL)
-                       free(menu_info->app_path);
-               if (menu_info->original_app_path != NULL)
-                       free(menu_info->original_app_path);
-               if (menu_info->hwacc != NULL)
-                       free(menu_info->hwacc);
-               free(menu_info);
-       }
+    if (menu_info != NULL) {
+        if (menu_info->pkg_name != NULL) {
+            free(menu_info->pkg_name);
+        }
+        if (menu_info->app_path != NULL) {
+            free(menu_info->app_path);
+        }
+        if (menu_info->original_app_path != NULL) {
+            free(menu_info->original_app_path);
+        }
+        if (menu_info->hwacc != NULL) {
+            free(menu_info->hwacc);
+        }
+        free(menu_info);
+    }
 }
 
 static inline app_info_from_db *_get_app_info_from_db_by_pkgname(
-                                                       const char *pkgname)
+    const char *pkgname)
 {
-       app_info_from_db *menu_info;
-       ail_appinfo_h handle;
-       ail_error_e ret;
-       char *str = NULL;
-
-       menu_info = calloc(1, sizeof(app_info_from_db));
-       if (menu_info == NULL) {
-               return NULL;
-       }
-
-       ret = ail_get_appinfo(pkgname, &handle);
-       if (ret != AIL_ERROR_OK) {
-               _free_app_info_from_db(menu_info);
-               return NULL;
-       }
-
-       ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &str);
-       if (str) {
-               menu_info->pkg_name = strdup(str);      
-               str = NULL;
-       }
-
-       ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &str);
-       if (str) {
-               menu_info->app_path = strdup(str);
-               str = NULL;
-       }
-
-       if (menu_info->app_path != NULL)
-               menu_info->original_app_path = strdup(menu_info->app_path);
-
-       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
-       if (str) {
-               menu_info->pkg_type = strdup(str);
-               str = NULL;
-       }
-       
-       ret = ail_destroy_appinfo(handle);
-       if (ret != AIL_ERROR_OK) {
-               _E("ail_destroy_appinfo failed");
-       }
-
-       if (!_get_app_path(menu_info)) {
-               _free_app_info_from_db(menu_info);
-               return NULL;
-       }
-
-       return menu_info;
+    app_info_from_db *menu_info;
+    ail_appinfo_h handle;
+    ail_error_e ret;
+    char *str = NULL;
+
+    menu_info = calloc(1, sizeof(app_info_from_db));
+    if (menu_info == NULL) {
+        return NULL;
+    }
+
+    ret = ail_get_appinfo(pkgname, &handle);
+    if (ret != AIL_ERROR_OK) {
+        _free_app_info_from_db(menu_info);
+        return NULL;
+    }
+
+    ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &str);
+    if (str) {
+        menu_info->pkg_name = strdup(str);
+        str = NULL;
+    }
+
+    ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &str);
+    if (str) {
+        menu_info->app_path = strdup(str);
+        str = NULL;
+    }
+
+    if (menu_info->app_path != NULL) {
+        menu_info->original_app_path = strdup(menu_info->app_path);
+    }
+
+    ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
+    if (str) {
+        menu_info->pkg_type = strdup(str);
+        str = NULL;
+    }
+
+    ret = ail_destroy_appinfo(handle);
+    if (ret != AIL_ERROR_OK) {
+        _E("ail_destroy_appinfo failed");
+    }
+
+    if (!_get_app_path(menu_info)) {
+        _free_app_info_from_db(menu_info);
+        return NULL;
+    }
+
+    return menu_info;
 }
 
-static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo,
+                                          void *user_data)
 {
-       app_info_from_db *menu_info = (app_info_from_db *)user_data;
-       char *package;
+    app_info_from_db *menu_info = (app_info_from_db *)user_data;
+    char *package;
+
+    ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
 
-       ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+    menu_info->pkg_name = strdup(package);
 
-       menu_info->pkg_name = strdup(package);
-       
-       return AIL_CB_RET_CANCEL;       /*return AIL_CB_RET_CONTINUE;*/ 
+    return AIL_CB_RET_CANCEL;           /*return AIL_CB_RET_CONTINUE;*/
 }
 
 static inline app_info_from_db *_get_app_info_from_db_by_apppath(
-                                                       const char *apppath)
+    const char *apppath)
 {
-       app_info_from_db *menu_info = NULL;
-       ail_filter_h filter;
-       ail_error_e ret;
-       int count;
-       
-       if (apppath == NULL)
-               return NULL;
-
-       menu_info = calloc(1, sizeof(app_info_from_db));
-       if (menu_info == NULL)
-               return NULL;
-
-       ret = ail_filter_new(&filter);
-       if (ret != AIL_ERROR_OK) {
-               _free_app_info_from_db(menu_info);
-               return NULL;
-       }
-
-       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, apppath);
-       if (ret != AIL_ERROR_OK) {
-               ail_filter_destroy(filter);
-               _free_app_info_from_db(menu_info);
-               return NULL;
-       }
-
-       ret = ail_filter_count_appinfo(filter, &count);
-       if (ret != AIL_ERROR_OK) {
-               ail_filter_destroy(filter);
-               _free_app_info_from_db(menu_info);
-               return NULL;
-       }
-       if (count < 1) {
-               ail_filter_destroy(filter);
-               _free_app_info_from_db(menu_info);
-               return NULL;
-       }
-
-       ail_filter_list_appinfo_foreach(filter, __appinfo_func, (void *)menu_info);
-
-       ail_filter_destroy(filter);
-
-       menu_info->app_path = strdup(apppath);
-       menu_info->original_app_path = strdup(apppath);
-
-       return menu_info;
-       
+    app_info_from_db *menu_info = NULL;
+    ail_filter_h filter;
+    ail_error_e ret;
+    int count;
+
+    if (apppath == NULL) {
+        return NULL;
+    }
+
+    menu_info = calloc(1, sizeof(app_info_from_db));
+    if (menu_info == NULL) {
+        return NULL;
+    }
+
+    ret = ail_filter_new(&filter);
+    if (ret != AIL_ERROR_OK) {
+        _free_app_info_from_db(menu_info);
+        return NULL;
+    }
+
+    ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, apppath);
+    if (ret != AIL_ERROR_OK) {
+        ail_filter_destroy(filter);
+        _free_app_info_from_db(menu_info);
+        return NULL;
+    }
+
+    ret = ail_filter_count_appinfo(filter, &count);
+    if (ret != AIL_ERROR_OK) {
+        ail_filter_destroy(filter);
+        _free_app_info_from_db(menu_info);
+        return NULL;
+    }
+    if (count < 1) {
+        ail_filter_destroy(filter);
+        _free_app_info_from_db(menu_info);
+        return NULL;
+    }
+
+    ail_filter_list_appinfo_foreach(filter, __appinfo_func, (void *)menu_info);
+
+    ail_filter_destroy(filter);
+
+    menu_info->app_path = strdup(apppath);
+    menu_info->original_app_path = strdup(apppath);
+
+    return menu_info;
 }
 
index 35b0926..831e086 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #ifndef __PERF_H__
 #define __PERF_H__
 
 
 #include <sys/time.h>
 static struct timeval __g_base_time = {
-       .tv_sec = 0,
-       .tv_usec = 0
+    .tv_sec = 0,
+    .tv_usec = 0
 };
 
-#define INIT_PERF(kb)\
-do {\
-       const char *tmp;\
-       struct timeval tv;\
-       tmp = bundle_get_val(kb, AUL_K_STARTTIME);\
-       if (tmp != NULL)\
-               sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec);\
-       else\
-               gettimeofday(&tv, NULL);\
-       __g_base_time.tv_sec = tv.tv_sec;\
-       __g_base_time.tv_usec = tv.tv_usec;\
-} while (0);
-
-#define PERF(fmt, arg...)\
-do {\
-       struct timeval cur;\
-       struct timeval res;\
-       gettimeofday(&cur, NULL);\
-       if (__g_base_time.tv_sec != 0) {\
-               timersub(&cur, &__g_base_time, &res);\
-               printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt" %c[0m\n",\
-                       27, __FUNCTION__, __LINE__, \
-                               res.tv_sec, res.tv_usec/1000, ##arg, 27);\
-       } \
-} while (0);
+#define INIT_PERF(kb) \
+    do { \
+        const char *tmp; \
+        struct timeval tv; \
+        tmp = bundle_get_val(kb, AUL_K_STARTTIME); \
+        if (tmp != NULL) { \
+            sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec); } \
+        else { \
+            gettimeofday(&tv, NULL); } \
+        __g_base_time.tv_sec = tv.tv_sec; \
+        __g_base_time.tv_usec = tv.tv_usec; \
+    } while (0);
+
+#define PERF(fmt, arg ...) \
+    do { \
+        struct timeval cur; \
+        struct timeval res; \
+        gettimeofday(&cur, NULL); \
+        if (__g_base_time.tv_sec != 0) { \
+            timersub(&cur, &__g_base_time, &res); \
+            printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt " %c[0m\n", \
+                   27, __FUNCTION__, __LINE__, \
+                   res.tv_sec, res.tv_usec / 1000,##arg, 27); \
+        } \
+    } while (0);
 
 #else
 
 #define INIT_PERF(kb)
-#define PERF(fmt, arg...)
+#define PERF(fmt, arg ...)
 
 #endif
 
index 168078d..06d0ccf 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #ifndef __SIMPLE_UTIL__
 #define __SIMPLE_UTIL__
 
 #define LOG_TAG "AUL_AMD"
 #endif
 
-
 #define MAX_LOCAL_BUFSZ 128
 #define MAX_PID_STR_BUFSZ 20
 
-#define _E(fmt, arg...) LOGE(fmt, ##arg)
-#define _D(fmt, arg...) LOGD(fmt, ##arg)
+#define _E(fmt, arg ...) LOGE(fmt,##arg)
+#define _D(fmt, arg ...) LOGD(fmt,##arg)
 
-#define retvm_if(expr, val, fmt, arg...) do { \
-       if (expr) { \
-               _E(fmt, ##arg); \
-               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
-               return (val); \
-       } \
+#define retvm_if(expr, val, fmt, arg ...) do { \
+        if (expr) { \
+            _E(fmt,##arg); \
+            _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+            return (val); \
+        } \
 } while (0)
 
 #define retv_if(expr, val) do { \
-       if (expr) { \
-               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
-               return (val); \
-       } \
+        if (expr) { \
+            _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+            return (val); \
+        } \
 } while (0)
 
 int __proc_iter_cmdline(int (*iterfunc)
-                        (const char *dname, const char *cmdline, void *priv),
-                       void *priv);
-int __proc_iter_pgid(int pgid, int (*iterfunc) (int pid, void *priv),
-                    void *priv);
+                        (const char *dname, const char *cmdline, void *priv),
+                        void *priv);
+int __proc_iter_pgid(int pgid, int (*iterfunc)(int pid, void *priv),
+                     void *priv);
 char *__proc_get_cmdline_bypid(int pid);
 
 static inline const char *FILENAME(const char *filename)
 {
-       const char *p;
-       const char *r;
+    const char *p;
+    const char *r;
 
-       if (!filename)
-               return NULL;
+    if (!filename) {
+        return NULL;
+    }
 
-       r = p = filename;
-       while (*p) {
-               if (*p == '/')
-                       r = p + 1;
-               p++;
-       }
+    r = p = filename;
+    while (*p) {
+        if (*p == '/') {
+            r = p + 1;
+        }
+        p++;
+    }
 
-       return r;
+    return r;
 }
 
 #endif
index 3404ea4..52045d4 100644 (file)
  *    limitations under the License.
  */
 
-
 #ifdef DAC_ACTIVATE
 
 #include <privilege-control.h>
 
 #define INHOUSE_UID     5000
-static inline int __set_access(const char* pkg_name, const char* pkg_type, const char* app_path)
+static inline int __set_access(const char* pkg_name,
+                               const char* pkg_type,
+                               const char* app_path)
 {
-       return set_app_privilege(pkg_name, pkg_type, app_path);
+    return set_app_privilege(pkg_name, pkg_type, app_path);
 }
 
 #else
 
-static inline int __set_access(const char* pkg_name, const char* pkg_type, const char* app_path)
+static inline int __set_access(const char* pkg_name,
+                               const char* pkg_type,
+                               const char* app_path)
 {
-       return 0;
+    return 0;
 }
 
 #endif
 
-
index becd61d..a177ff5 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #define LAUNCHPAD_LOG
 #define DAC_ACTIVATE
 #define PRELOAD_ACTIVATE
index 98cf202..47ac8e0 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #ifdef GL_ACTIVATE
 
 #define USE_ENGINE(engine) setenv("ELM_ENGINE", engine, 1);
index dd73037..415519e 100644 (file)
@@ -14,9 +14,8 @@
  *    limitations under the License.
  */
 
-
 /*
- * simple AUL daemon - launchpad 
+ * simple AUL daemon - launchpad
  */
 
 #include <stdio.h>
 
 #define _static_ static inline
 #define POLLFD_MAX 1
-#define SQLITE_FLUSH_MAX       (1048576)       /* (1024*1024) */
-#define AUL_POLL_CNT           15
-#define AUL_PR_NAME                    16
+#define SQLITE_FLUSH_MAX        (1048576)       /* (1024*1024) */
+#define AUL_POLL_CNT            15
+#define AUL_PR_NAME                     16
+#define PKG_ID_LENGTH   11
 #define PATH_APP_ROOT "/opt/usr/apps"
 #define PATH_DATA "/data"
 #define SDK_CODE_COVERAGE "CODE_COVERAGE"
 #define SDK_DYNAMIC_ANALYSIS "DYNAMIC_ANALYSIS"
 #define PATH_DA_SO "/home/developer/sdk_tools/da/da_probe.so"
 
-
 static char *launchpad_cmdline;
 static int initialized = 0;
 
-
 _static_ void __set_oom();
 _static_ void __set_env(app_info_from_db * menu_info, bundle * kb);
 _static_ int __prepare_exec(const char *pkg_name,
-                           const char *app_path, app_info_from_db * menu_info,
-                           bundle * kb);
+                            const char *app_path, app_info_from_db * menu_info,
+                            bundle * kb);
 _static_ int __fake_launch_app(int cmd, int pid, bundle * kb);
 _static_ char **__create_argc_argv(bundle * kb, int *margc);
 _static_ int __normal_fork_exec(int argc, char **argv);
 _static_ void __real_launch(const char *app_path, bundle * kb);
 static inline int __parser(const char *arg, char *out, int out_size);
 _static_ void __modify_bundle(bundle * kb, int caller_pid,
-                           app_info_from_db * menu_info, int cmd);
+                              app_info_from_db * menu_info, int cmd);
 _static_ int __child_raise_win_by_x(int pid, void *priv);
 _static_ int __raise_win_by_x(int pid);
 _static_ int __send_to_sigkill(int pid);
@@ -95,197 +93,210 @@ _static_ int __launchpad_post_init();
 
 extern ail_error_e ail_db_close(void);
 
-
-
 _static_ void __set_oom()
 {
-       char buf[MAX_LOCAL_BUFSZ];
-       FILE *fp;
-
-       /* we should reset oomadj value as default because child 
-       inherits from parent oom_adj*/
-       snprintf(buf, MAX_LOCAL_BUFSZ, "/proc/%d/oom_adj", getpid());
-       fp = fopen(buf, "w");
-       if (fp == NULL)
-               return;
-       fprintf(fp, "%d", -16);
-       fclose(fp);
+    char buf[MAX_LOCAL_BUFSZ];
+    FILE *fp;
+
+    /* we should reset oomadj value as default because child
+     * inherits from parent oom_adj*/
+    snprintf(buf, MAX_LOCAL_BUFSZ, "/proc/%d/oom_adj", getpid());
+    fp = fopen(buf, "w");
+    if (fp == NULL) {
+        return;
+    }
+    fprintf(fp, "%d", -16);
+    fclose(fp);
 }
 
-_static_ void __set_sdk_env(app_info_from_db* menu_info, char* str) {
-       char buf[MAX_LOCAL_BUFSZ];
-       int ret;
-
-       _D("key : %s / value : %s", AUL_K_SDK, str);
-       /* http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html*/
-       /* GCOV_PREFIX contains the prefix to add to the absolute paths in the object file. */
-       /*              Prefix can be absolute, or relative. The default is no prefix.  */
-       /* GCOV_PREFIX_STRIP indicates the how many initial directory names */
-       /*              to stripoff the hardwired absolute paths. Default value is 0. */
-       if (strncmp(str, SDK_CODE_COVERAGE, strlen(str)) == 0) {
-               snprintf(buf, MAX_LOCAL_BUFSZ, PATH_APP_ROOT"/%s"PATH_DATA, _get_pkgname(menu_info));
-               ret = setenv("GCOV_PREFIX", buf, 1);
-               _D("GCOV_PREFIX : %d", ret);
-               ret = setenv("GCOV_PREFIX_STRIP", "4096", 1);
-               _D("GCOV_PREFIX_STRIP : %d", ret);
-       } else if (strncmp(str, SDK_DYNAMIC_ANALYSIS, strlen(str)) == 0) {
-               ret = setenv("LD_PRELOAD", PATH_DA_SO, 1);
-               _D("LD_PRELOAD : %d", ret);
-       }
+_static_ void __set_sdk_env(app_info_from_db* menu_info, char* str)
+{
+    char buf[MAX_LOCAL_BUFSZ];
+    int ret;
+
+    _D("key : %s / value : %s", AUL_K_SDK, str);
+    /* http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html*/
+    /* GCOV_PREFIX contains the prefix to add to the absolute paths in the
+     *object file. */
+    /*         Prefix can be absolute, or relative. The default is no prefix.
+     * */
+    /* GCOV_PREFIX_STRIP indicates the how many initial directory names */
+    /*         to stripoff the hardwired absolute paths. Default value is 0. */
+    if (strncmp(str, SDK_CODE_COVERAGE, strlen(str)) == 0) {
+        snprintf(buf,
+                 MAX_LOCAL_BUFSZ,
+                 PATH_APP_ROOT "/%s"PATH_DATA,
+                 _get_pkgname(menu_info));
+        ret = setenv("GCOV_PREFIX", buf, 1);
+        _D("GCOV_PREFIX : %d", ret);
+        ret = setenv("GCOV_PREFIX_STRIP", "4096", 1);
+        _D("GCOV_PREFIX_STRIP : %d", ret);
+    } else if (strncmp(str, SDK_DYNAMIC_ANALYSIS, strlen(str)) == 0) {
+        ret = setenv("LD_PRELOAD", PATH_DA_SO, 1);
+        _D("LD_PRELOAD : %d", ret);
+    }
 }
 
-
 _static_ void __set_env(app_info_from_db * menu_info, bundle * kb)
 {
-       const char *str;
-       const char **str_array;
-       int len;
-       int i;
-
-       setenv("PKG_NAME", _get_pkgname(menu_info), 1);
-
-       USE_ENGINE("gl")
-
-       str = bundle_get_val(kb, AUL_K_STARTTIME);
-       if (str != NULL)
-               setenv("APP_START_TIME", str, 1);
-
-       if(bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY) {
-               str_array = bundle_get_str_array(kb, AUL_K_SDK, &len);
-               if(str_array != NULL) {
-                       for (i = 0; i < len; i++) {
-                               _D("index : [%d]", i);
-                               __set_sdk_env(menu_info, (char *)str_array[i]);
-                       }
-               }
-       } else {
-               str = bundle_get_val(kb, AUL_K_SDK);
-               if(str != NULL) {
-                       __set_sdk_env(menu_info, (char *)str);
-               }
-       }
-       if (menu_info->hwacc != NULL)
-               setenv("HWACC", menu_info->hwacc, 1);
+    const char *str;
+
+    setenv("PKG_NAME", _get_pkgname(menu_info), 1);
+
+    USE_ENGINE("gl")
+
+    str = bundle_get_val(kb, AUL_K_STARTTIME);
+    if (str != NULL) {
+        setenv("APP_START_TIME", str, 1);
+    }
+
+    if (bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY) {
+        int len;
+        const char **str_array;
+        str_array = bundle_get_str_array(kb, AUL_K_SDK, &len);
+        if (str_array != NULL) {
+            int i;
+            for (i = 0; i < len; i++) {
+                _D("index : [%d]", i);
+                __set_sdk_env(menu_info, (char *)str_array[i]);
+            }
+        }
+    } else {
+        str = bundle_get_val(kb, AUL_K_SDK);
+        if (str != NULL) {
+            __set_sdk_env(menu_info, (char *)str);
+        }
+    }
+    if (menu_info->hwacc != NULL) {
+        setenv("HWACC", menu_info->hwacc, 1);
+    }
 }
 
 _static_ int __prepare_exec(const char *pkg_name,
-                           const char *app_path, app_info_from_db * menu_info,
-                           bundle * kb)
+                            const char *app_path, app_info_from_db * menu_info,
+                            bundle * kb)
 {
-       char *file_name;
-       char process_name[AUL_PR_NAME];
-
-       /* Set new session ID & new process group ID*/
-       /* In linux, child can set new session ID without check permission */
-       /* TODO : should be add to check permission in the kernel*/
-       setsid();
-
-       __preexec_run(menu_info->pkg_type, pkg_name, app_path);
-
-       /* SET OOM*/
-       __set_oom();
-
-       /* SET PRIVILEGES*/
-       if (__set_access(pkg_name, menu_info->pkg_type, app_path) < 0) {
-                _D("fail to set privileges - check your package's credential\n");
-               return -1;
-       }
-       /* SET DUMPABLE - for coredump*/
-       prctl(PR_SET_DUMPABLE, 1);
-
-       /* SET PROCESS NAME*/
-       if (app_path == NULL) {
-               _D("app_path should not be NULL - check menu db");
-               return -1;
-       }
-       file_name = strrchr(app_path, '/') + 1;
-       if (file_name == NULL) {
-               _D("can't locate file name to execute");
-               return -1;
-       }
-       memset(process_name, '\0', AUL_PR_NAME);
-       snprintf(process_name, AUL_PR_NAME, "%s", file_name);
-       prctl(PR_SET_NAME, process_name);
-
-       /* SET ENVIROMENT*/
-       __set_env(menu_info, kb);
-
-       return 0;
+    char *file_name;
+    char process_name[AUL_PR_NAME];
+
+    /* Set new session ID & new process group ID*/
+    /* In linux, child can set new session ID without check permission */
+    /* TODO : should be add to check permission in the kernel*/
+    setsid();
+
+    __preexec_run(menu_info->pkg_type, pkg_name, app_path);
+
+    /* SET OOM*/
+    __set_oom();
+
+    /* SET PRIVILEGES*/
+    char pkg_id[PKG_ID_LENGTH];
+    memset(pkg_id, '\0', PKG_ID_LENGTH);
+    snprintf(pkg_id, PKG_ID_LENGTH, "%s", pkg_name);
+
+    if (__set_access(pkg_id, menu_info->pkg_type, app_path) < 0) {
+        _D("fail to set privileges - check your package's credential\n");
+        return -1;
+    }
+    /* SET DUMPABLE - for coredump*/
+    prctl(PR_SET_DUMPABLE, 1);
+
+    /* SET PROCESS NAME*/
+    if (app_path == NULL) {
+        _D("app_path should not be NULL - check menu db");
+        return -1;
+    }
+    file_name = strrchr(app_path, '/') + 1;
+    if (file_name == NULL) {
+        _D("can't locate file name to execute");
+        return -1;
+    }
+    memset(process_name, '\0', AUL_PR_NAME);
+    snprintf(process_name, AUL_PR_NAME, "%s", file_name);
+    prctl(PR_SET_NAME, process_name);
+
+    /* SET ENVIROMENT*/
+    __set_env(menu_info, kb);
+
+    return 0;
 }
 
 _static_ int __fake_launch_app(int cmd, int pid, bundle * kb)
 {
-       int datalen;
-       int ret;
-       bundle_raw *kb_data;
-
-       bundle_encode(kb, &kb_data, &datalen);
-       if ((ret = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
-               _E("error request fake launch - error code = %d", ret);
-       free(kb_data);
-       return ret;
+    int datalen;
+    int ret;
+    bundle_raw *kb_data;
+
+    bundle_encode(kb, &kb_data, &datalen);
+    if ((ret = __app_send_raw(pid, cmd, kb_data, datalen)) < 0) {
+        _E("error request fake launch - error code = %d", ret);
+    }
+    free(kb_data);
+    return ret;
 }
 
 _static_ char **__create_argc_argv(bundle * kb, int *margc)
 {
-       char **argv;
-       int argc;
+    char **argv;
+    int argc;
 
-       argc = bundle_export_to_argv(kb, &argv);
+    argc = bundle_export_to_argv(kb, &argv);
 
-       *margc = argc;
-       return argv;
+    *margc = argc;
+    return argv;
 }
 
 _static_ int __normal_fork_exec(int argc, char **argv)
 {
-       _D("start real fork and exec\n");
-
-        // warning: unused parameter
-        argc = argc;
-
-       if (execv(argv[0], argv) < 0) { /* Flawfinder: ignore */
-               if (errno == EACCES)
-                       _E("such a file is no executable - %s", argv[0]);
-               else
-                       _E("unknown executable error - %s", argv[0]);
-               return -1;
-       }
-       /* never reach*/
-       return 0;
+    _D("start real fork and exec\n");
+
+    // warning: unused parameter
+    (void)argc;
+
+    if (execv(argv[0], argv) < 0) {     /* Flawfinder: ignore */
+        if (errno == EACCES) {
+            _E("such a file is no executable - %s", argv[0]);
+        } else {
+            _E("unknown executable error - %s", argv[0]);
+        }
+        return -1;
+    }
+    /* never reach*/
+    return 0;
 }
 
 _static_ void __real_launch(const char *app_path, bundle * kb)
 {
-       int app_argc;
-       char **app_argv;
-       int i;
+    int app_argc;
+    char **app_argv;
+    int i;
 
-       app_argv = __create_argc_argv(kb, &app_argc);
+    app_argv = __create_argc_argv(kb, &app_argc);
 
 #ifndef NATIVE_LAUNCHPAD
-    if (__change_cmdline(app_path) < 0) {
+    if (__change_cmdline((char *)app_path) < 0) {
         _E("change cmdline fail");
         return;
     }
 
     app_argv[0] = g_argv[0];
 #else
-       app_argv[0] = strdup(app_path);
+    app_argv[0] = strdup(app_path);
 #endif
 
-       for (i = 0; i < app_argc; i++)
-               _D("input argument %d : %s##", i, app_argv[i]);
+    for (i = 0; i < app_argc; i++) {
+        _D("input argument %d : %s##", i, app_argv[i]);
+    }
 
-       PERF("setup argument done");
-       _E("lock up test log(no error) : setup argument done");
+    PERF("setup argument done");
+    _E("lock up test log(no error) : setup argument done");
 
-       /* Temporary log: launch time checking */
-       LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
+    /* Temporary log: launch time checking */
+    LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
 
-       __preload_exec(app_argc, app_argv);
+    __preload_exec(app_argc, app_argv);
 
-       __normal_fork_exec(app_argc, app_argv);
+    __normal_fork_exec(app_argc, app_argv);
 }
 
 /*
@@ -297,551 +308,576 @@ _static_ void __real_launch(const char *app_path, bundle * kb)
  */
 static inline int __parser(const char *arg, char *out, int out_size)
 {
-       register int i;
-       int state = 1;
-       char *start_out = out;
-
-       if (arg == NULL || out == NULL) {
-               /* Handles null buffer*/
-               return 0;
-       }
-
-       for (i = 0; out_size > 1; i++) {
-               switch (state) {
-               case 1:
-                       switch (arg[i]) {
-                       case ' ':
-                       case '\t':
-                               state = 5;
-                               break;
-                       case '\0':
-                               state = 7;
-                               break;
-                       case '\"':
-                               state = 2;
-                               break;
-                       case '\\':
-                               state = 4;
-                               break;
-                       default:
-                               *out = arg[i];
-                               out++;
-                               out_size--;
-                               break;
-                       }
-                       break;
-               case 2: /* escape start*/
-                       switch (arg[i]) {
-                       case '\0':
-                               state = 6;
-                               break;
-                       case '\"':
-                               state = 1;
-                               break;
-                       default:
-                               *out = arg[i];
-                               out++;
-                               out_size--;
-                               break;
-                       }
-                       break;
-               case 4: /* character escape*/
-                       if (arg[i] == '\0') {
-                               state = 6;
-                       } else {
-                               *out = arg[i];
-                               out++;
-                               out_size--;
-                               state = 1;
-                       }
-                       break;
-               case 5: /* token*/
-                       if (out != start_out) {
-                               *out = '\0';
-                               out_size--;
-                               return i;
-                       }
-                       i--;
-                       state = 1;
-                       break;
-               case 6:
-                       return -1;      /* error*/
-               case 7: /* terminate*/
-                       *out = '\0';
-                       out_size--;
-                       return 0;
-               default:
-                       state = 6;
-                       break;  /* error*/
-               }
-       }
-
-       if (out_size == 1) {
-               *out = '\0';
-       }
-       /* Buffer overflow*/
-       return -2;
+    register int i;
+    int state = 1;
+    char *start_out = out;
+
+    if (arg == NULL || out == NULL) {
+        /* Handles null buffer*/
+        return 0;
+    }
+
+    for (i = 0; out_size > 1; i++) {
+        switch (state) {
+        case 1:
+            switch (arg[i]) {
+            case ' ':
+            case '\t':
+                state = 5;
+                break;
+            case '\0':
+                state = 7;
+                break;
+            case '\"':
+                state = 2;
+                break;
+            case '\\':
+                state = 4;
+                break;
+            default:
+                *out = arg[i];
+                out++;
+                out_size--;
+                break;
+            }
+            break;
+        case 2:         /* escape start*/
+            switch (arg[i]) {
+            case '\0':
+                state = 6;
+                break;
+            case '\"':
+                state = 1;
+                break;
+            default:
+                *out = arg[i];
+                out++;
+                out_size--;
+                break;
+            }
+            break;
+        case 4:         /* character escape*/
+            if (arg[i] == '\0') {
+                state = 6;
+            } else {
+                *out = arg[i];
+                out++;
+                out_size--;
+                state = 1;
+            }
+            break;
+        case 5:         /* token*/
+            if (out != start_out) {
+                *out = '\0';
+                out_size--;
+                return i;
+            }
+            i--;
+            state = 1;
+            break;
+        case 6:
+            return -1;                  /* error*/
+        case 7:         /* terminate*/
+            *out = '\0';
+            out_size--;
+            return 0;
+        default:
+            state = 6;
+            break;              /* error*/
+        }
+    }
+
+    if (out_size == 1) {
+        *out = '\0';
+    }
+    /* Buffer overflow*/
+    return -2;
 }
 
 _static_ void __modify_bundle(bundle * kb, int caller_pid,
-                           app_info_from_db * menu_info, int cmd)
+                              app_info_from_db * menu_info, int cmd)
 {
-        // warning: unused parameter
-        caller_pid = caller_pid;
-
-       bundle_del(kb, AUL_K_PKG_NAME);
-       bundle_del(kb, AUL_K_EXEC);
-       bundle_del(kb, AUL_K_PACKAGETYPE);
-       bundle_del(kb, AUL_K_HWACC);
-
-       /* Parse app_path to retrieve default bundle*/
-       if (cmd == APP_START || cmd == APP_START_RES || cmd == APP_OPEN || cmd == APP_RESUME) {
-               char *ptr;
-               char exe[MAX_PATH_LEN];
-               int flag;
-
-               ptr = _get_original_app_path(menu_info);
-
-               flag = __parser(ptr, exe, sizeof(exe));
-               if (flag > 0) {
-                       char key[256];
-                       char value[256];
-
-                       ptr += flag;
-                       _D("parsing app_path: EXEC - %s\n", exe);
-
-                       do {
-                               flag = __parser(ptr, key, sizeof(key));
-                               if (flag <= 0)
-                                       break;
-                               ptr += flag;
-
-                               flag = __parser(ptr, value, sizeof(value));
-                               if (flag < 0)
-                                       break;
-                               ptr += flag;
-
-                               /*bundle_del(kb, key);*/
-                               bundle_add(kb, key, value);
-                       } while (flag > 0);
-               } else if (flag == 0) {
-                       _D("parsing app_path: No arguments\n");
-               } else {
-                       _D("parsing app_path: Invalid argument\n");
-               }
-       }
+    // warning: unused parameter
+    (void)caller_pid;
+
+    bundle_del(kb, AUL_K_PKG_NAME);
+    bundle_del(kb, AUL_K_EXEC);
+    bundle_del(kb, AUL_K_PACKAGETYPE);
+    bundle_del(kb, AUL_K_HWACC);
+
+    /* Parse app_path to retrieve default bundle*/
+    if (cmd == APP_START || cmd == APP_START_RES || cmd == APP_OPEN || cmd ==
+        APP_RESUME)
+    {
+        char *ptr;
+        char exe[MAX_PATH_LEN];
+        int flag;
+
+        ptr = _get_original_app_path(menu_info);
+
+        flag = __parser(ptr, exe, sizeof(exe));
+        if (flag > 0) {
+            char key[256];
+            char value[256];
+
+            ptr += flag;
+            _D("parsing app_path: EXEC - %s\n", exe);
+
+            do {
+                flag = __parser(ptr, key, sizeof(key));
+                if (flag <= 0) {
+                    break;
+                }
+                ptr += flag;
+
+                flag = __parser(ptr, value, sizeof(value));
+                if (flag < 0) {
+                    break;
+                }
+                ptr += flag;
+
+                /*bundle_del(kb, key);*/
+                bundle_add(kb, key, value);
+            } while (flag > 0);
+        } else if (flag == 0) {
+            _D("parsing app_path: No arguments\n");
+        } else {
+            _D("parsing app_path: Invalid argument\n");
+        }
+    }
 }
 
 _static_ int __child_raise_win_by_x(int pid, void *priv)
 {
-        // warning: unused parameter
-        priv = priv;
+    // warning: unused parameter
+    priv = priv;
 
-       return x_util_raise_win(pid);
+    return x_util_raise_win(pid);
 }
 
 _static_ int __raise_win_by_x(int pid)
 {
-       int pgid;
-       if (x_util_raise_win(pid) == 0)
-               return 0;
+    int pgid;
+    if (x_util_raise_win(pid) == 0) {
+        return 0;
+    }
 
-       /* support app launched by shell script*/
-       pgid = getpgid(pid);
-       _D("X raise failed. try to find first child & raise it - c:%d p:%d\n",
-          pgid, pid);
+    /* support app launched by shell script*/
+    pgid = getpgid(pid);
+    _D("X raise failed. try to find first child & raise it - c:%d p:%d\n",
+       pgid, pid);
 
-       if (pgid <= 1)
-               return -1;
-       if (__proc_iter_pgid(pgid, __child_raise_win_by_x, NULL) < 0)
-               return -1;
+    if (pgid <= 1) {
+        return -1;
+    }
+    if (__proc_iter_pgid(pgid, __child_raise_win_by_x, NULL) < 0) {
+        return -1;
+    }
 
-       return 0;
+    return 0;
 }
 
 _static_ int __send_to_sigkill(int pid)
 {
-       int pgid;
+    int pgid;
 
-       pgid = getpgid(pid);
-       if (pgid <= 1)
-               return -1;
+    pgid = getpgid(pid);
+    if (pgid <= 1) {
+        return -1;
+    }
 
-       if (killpg(pgid, SIGKILL) < 0)
-               return -1;
+    if (killpg(pgid, SIGKILL) < 0) {
+        return -1;
+    }
 
-       return 0;
+    return 0;
 }
 
 _static_ int __term_app(int pid)
 {
-       int dummy;
-       if (__app_send_raw
-           (pid, APP_TERM_BY_PID, (unsigned char *)&dummy, sizeof(int)) < 0) {
-               _D("terminate packet send error - use SIGKILL");
-               if (__send_to_sigkill(pid) < 0) {
-                       _E("fail to killing - %d\n", pid);
-                       return -1;
-               }
-       }
-       _D("term done\n");
-       return 0;
+    int dummy;
+    if (__app_send_raw
+            (pid, APP_TERM_BY_PID, (unsigned char *)&dummy, sizeof(int)) < 0)
+    {
+        _D("terminate packet send error - use SIGKILL");
+        if (__send_to_sigkill(pid) < 0) {
+            _E("fail to killing - %d\n", pid);
+            return -1;
+        }
+    }
+    _D("term done\n");
+    return 0;
 }
 
 _static_ int __resume_app(int pid)
 {
-       int dummy;
-       int ret;
-       if ((ret =
-            __app_send_raw(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
-                           sizeof(int))) < 0) {
-               if (ret == -EAGAIN)
-                       _E("resume packet timeout error");
-               else {
-                       _D("resume packet send error - use raise win");
-                       if (__raise_win_by_x(pid) < 0) {
-                               _E("raise failed - %d resume fail\n", pid);
-                               _E("we will term the app - %d\n", pid);
-                               __send_to_sigkill(pid);
-                               ret = -1;
-                       } else
-                               ret = 0;
-               }
-       }
-       _D("resume done\n");
-       return ret;
+    int dummy;
+    int ret;
+    if ((ret =
+             __app_send_raw(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
+                            sizeof(int))) < 0)
+    {
+        if (ret == -EAGAIN) {
+            _E("resume packet timeout error");
+        } else {
+            _D("resume packet send error - use raise win");
+            if (__raise_win_by_x(pid) < 0) {
+                _E("raise failed - %d resume fail\n", pid);
+                _E("we will term the app - %d\n", pid);
+                __send_to_sigkill(pid);
+                ret = -1;
+            } else {
+                ret = 0;
+            }
+        }
+    }
+    _D("resume done\n");
+    return ret;
 }
 
 static int __get_caller_pid(bundle *kb)
 {
-       const char *pid_str;
-       int pid;
+    const char *pid_str;
+    int pid;
 
-       pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID);
-       if(pid_str)
-               goto end;
+    pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID);
+    if (pid_str) {
+        goto end;
+    }
 
-       pid_str = bundle_get_val(kb, AUL_K_CALLER_PID);
-       if (pid_str == NULL)
-               return -1;
+    pid_str = bundle_get_val(kb, AUL_K_CALLER_PID);
+    if (pid_str == NULL) {
+        return -1;
+    }
 
 end:
-       pid = atoi(pid_str);
-       if (pid <= 1)
-               return -1;
+    pid = atoi(pid_str);
+    if (pid <= 1) {
+        return -1;
+    }
 
-       return pid;
+    return pid;
 }
 
 _static_ int __foward_cmd(int cmd, bundle *kb, int cr_pid)
 {
-       int pid;
-       char tmp_pid[MAX_PID_STR_BUFSZ];
-       int datalen;
-       bundle_raw *kb_data;
-       int res;
-
-       if ((pid = __get_caller_pid(kb)) < 0)
-                       return AUL_R_ERROR;
+    int pid;
+    char tmp_pid[MAX_PID_STR_BUFSZ];
+    int datalen;
+    bundle_raw *kb_data;
+    int res;
+
+    if ((pid = __get_caller_pid(kb)) < 0) {
+        return AUL_R_ERROR;
+    }
 
-       snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", cr_pid);
+    snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", cr_pid);
 
-       bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
+    bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
 
-       bundle_encode(kb, &kb_data, &datalen);
-       if ((res = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
-               res = AUL_R_ERROR;
+    bundle_encode(kb, &kb_data, &datalen);
+    if ((res = __app_send_raw(pid, cmd, kb_data, datalen)) < 0) {
+        res = AUL_R_ERROR;
+    }
 
-       free(kb_data);
+    free(kb_data);
 
-       return res;
+    return res;
 }
 
 _static_ void __real_send(int clifd, int ret)
 {
-       if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
-               if (errno == EPIPE) {
-                       _E("send failed due to EPIPE.\n");
-               }
-               _E("send fail to client");
-       }
-
-       close(clifd);
+    if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
+        if (errno == EPIPE) {
+            _E("send failed due to EPIPE.\n");
+        }
+        _E("send fail to client");
+    }
+
+    close(clifd);
 }
 
 _static_ void __send_result_to_caller(int clifd, int ret)
 {
-       char *cmdline;
-       int wait_count;
-       int cmdline_changed = 0;
-       int cmdline_exist = 0;
-
-       if (clifd == -1)
-               return;
-
-       if (ret <= 1) {
-               __real_send(clifd, ret);
-               return;
-       }
-       /* check normally was launched?*/
-       wait_count = 1;
-       do {
-               cmdline = __proc_get_cmdline_bypid(ret);
-               if (cmdline == NULL) {
-                       _E("error founded when being launched with %d", ret);
-
-               } else if (strcmp(cmdline, launchpad_cmdline)) {
-                       free(cmdline);
-                       cmdline_changed = 1;
-                       break;
-               } else {
-                       cmdline_exist = 1;
-                       free(cmdline);
-               }
-
-               _D("-- now wait to change cmdline --");
-               usleep(50 * 1000);      /* 50ms sleep*/
-               wait_count++;
-       } while (wait_count <= 20);     /* max 50*20ms will be sleep*/
-
-       if ((!cmdline_exist) && (!cmdline_changed)) {
-               __real_send(clifd, -1); /* abnormally launched*/
-               return;
-       }
-
-       if (!cmdline_changed)
-               _E("process launched, but cmdline not changed");
-
-       __real_send(clifd, ret);
-       return;
+    char *cmdline;
+    int wait_count;
+    int cmdline_changed = 0;
+    int cmdline_exist = 0;
+
+    if (clifd == -1) {
+        return;
+    }
+
+    if (ret <= 1) {
+        __real_send(clifd, ret);
+        return;
+    }
+    /* check normally was launched?*/
+    wait_count = 1;
+    do {
+        cmdline = __proc_get_cmdline_bypid(ret);
+        if (cmdline == NULL) {
+            _E("error founded when being launched with %d", ret);
+        } else if (strcmp(cmdline, launchpad_cmdline)) {
+            free(cmdline);
+            cmdline_changed = 1;
+            break;
+        } else {
+            cmdline_exist = 1;
+            free(cmdline);
+        }
+
+        _D("-- now wait to change cmdline --");
+        struct timespec duration = { 0, 50 * 1000 * 1000 };
+        nanosleep(&duration, NULL);     /* 50ms sleep*/
+        wait_count++;
+    } while (wait_count <= 20);         /* max 50*20ms will be sleep*/
+
+    if ((!cmdline_exist) && (!cmdline_changed)) {
+        __real_send(clifd, -1);         /* abnormally launched*/
+        return;
+    }
+
+    if (!cmdline_changed) {
+        _E("process launched, but cmdline not changed");
+    }
+
+    __real_send(clifd, ret);
+    return;
 }
 
 static app_info_from_db *_get_app_info_from_bundle_by_pkgname(
-                                                       const char *pkgname, bundle *kb)
+    const char *pkgname, bundle *kb)
 {
-       app_info_from_db *menu_info;
-
-       menu_info = calloc(1, sizeof(app_info_from_db));
-       if (menu_info == NULL) {
-               return NULL;
-       }
-
-       menu_info->pkg_name = strdup(pkgname);
-       menu_info->app_path = strdup(bundle_get_val(kb, AUL_K_EXEC));
-       if (menu_info->app_path != NULL)
-               menu_info->original_app_path = strdup(menu_info->app_path);
-       menu_info->pkg_type = strdup(bundle_get_val(kb, AUL_K_PACKAGETYPE));
-       menu_info->hwacc = strdup(bundle_get_val(kb, AUL_K_HWACC));
-
-       if (!_get_app_path(menu_info)) {
-               _free_app_info_from_db(menu_info);
-               return NULL;
-       }
-
-       return menu_info;
+    app_info_from_db *menu_info;
+
+    menu_info = calloc(1, sizeof(app_info_from_db));
+    if (menu_info == NULL) {
+        return NULL;
+    }
+
+    menu_info->pkg_name = strdup(pkgname);
+    menu_info->app_path = strdup(bundle_get_val(kb, AUL_K_EXEC));
+    if (menu_info->app_path != NULL) {
+        menu_info->original_app_path = strdup(menu_info->app_path);
+    }
+    menu_info->pkg_type = strdup(bundle_get_val(kb, AUL_K_PACKAGETYPE));
+    menu_info->hwacc = strdup(bundle_get_val(kb, AUL_K_HWACC));
+
+    if (!_get_app_path(menu_info)) {
+        _free_app_info_from_db(menu_info);
+        return NULL;
+    }
+
+    return menu_info;
 }
 
 _static_ void __launchpad_main_loop(int main_fd)
 {
-       bundle *kb = NULL;
-       app_pkt_t *pkt = NULL;
-       app_info_from_db *menu_info = NULL;
-
-       const char *pkg_name = NULL;
-       const char *app_path = NULL;
-       int pid = -1;
-       int clifd = -1;
-       struct ucred cr;
-       int is_real_launch = 0;
-
-       char sock_path[UNIX_PATH_MAX] = {0,};
-
-       pkt = __app_recv_raw(main_fd, &clifd, &cr);
-       if (!pkt) {
-               _D("packet is NULL");
-               goto end;
-       }
-
-       kb = bundle_decode(pkt->data, pkt->len);
-       if (!kb) {
-               _D("bundle decode error");
-               goto end;
-       }
-
-       INIT_PERF(kb);
-       PERF("packet processing start");
-
-       pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
-       _D("pkg name : %s\n", pkg_name);
-
-       menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
-       if (menu_info == NULL) {
-               _D("such pkg no found");
-               goto end;
-       }
-
-       app_path = _get_app_path(menu_info);
-       if(app_path == NULL) {
-               _E("app_path is NULL");
-               goto end;
-       }
-       if (app_path[0] != '/') {
-               _D("app_path is not absolute path");
-               goto end;
-       }
-
-       __modify_bundle(kb, cr.pid, menu_info, pkt->cmd);
-       pkg_name = _get_pkgname(menu_info);
-
-       PERF("get package information & modify bundle done");
-
-       {
-               pid = fork();
-               if (pid == 0) {
-                       PERF("fork done");
-                       _E("lock up test log(no error) : fork done");
-
-                       close(clifd);
-                       close(main_fd);
-                       __signal_unset_sigchld();
-                       __signal_fini();
-
-                       snprintf(sock_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, getpid());
-                       unlink(sock_path);
-
-                       PERF("prepare exec - first done");
-                       _E("lock up test log(no error) : prepare exec - first done");
-
-                       if (__prepare_exec(pkg_name, app_path,
-                                          menu_info, kb) < 0) {
-                               _E("preparing work fail to launch - "
-                                  "can not launch %s\n", pkg_name);
-                               exit(-1);
-                       }
-
-                       PERF("prepare exec - second done");
-                       _E("lock up test log(no error) : prepare exec - second done");
-
-                       __real_launch(app_path, kb);
-
-                       exit(-1);
-               }
-               _D("==> real launch pid : %d %s\n", pid, app_path);
-               is_real_launch = 1;
-       }
-
- end:
-       __send_result_to_caller(clifd, pid);
-
-       if (pid > 0) {
-               if (is_real_launch) {
-                       /*TODO: retry*/
-                       __signal_block_sigchld();
-                       __send_app_launch_signal(pid);
-                       __signal_unblock_sigchld();
-               }
-       }
-
-       if (menu_info != NULL)
-               _free_app_info_from_db(menu_info);
-
-       if (kb != NULL)
-               bundle_free(kb);
-       if (pkt != NULL)
-               free(pkt);
-
-       /* Active Flusing for Daemon */
-       if (initialized > AUL_POLL_CNT) {
-               sqlite3_release_memory(SQLITE_FLUSH_MAX);
-               malloc_trim(0);
-               initialized = 1;
-       }
+    bundle *kb = NULL;
+    app_pkt_t *pkt = NULL;
+    app_info_from_db *menu_info = NULL;
+
+    const char *pkg_name = NULL;
+    const char *app_path = NULL;
+    int pid = -1;
+    int clifd = -1;
+    struct ucred cr;
+    int is_real_launch = 0;
+
+    char sock_path[UNIX_PATH_MAX] = { 0, };
+
+    pkt = __app_recv_raw(main_fd, &clifd, &cr);
+    if (!pkt) {
+        _D("packet is NULL");
+        goto end;
+    }
+
+    kb = bundle_decode(pkt->data, pkt->len);
+    if (!kb) {
+        _D("bundle decode error");
+        goto end;
+    }
+
+    INIT_PERF(kb);
+    PERF("packet processing start");
+
+    pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
+    _D("pkg name : %s\n", pkg_name);
+
+    menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
+    if (menu_info == NULL) {
+        _D("such pkg no found");
+        goto end;
+    }
+
+    app_path = _get_app_path(menu_info);
+    if (app_path == NULL) {
+        _E("app_path is NULL");
+        goto end;
+    }
+    if (app_path[0] != '/') {
+        _D("app_path is not absolute path");
+        goto end;
+    }
 
+    __modify_bundle(kb, cr.pid, menu_info, pkt->cmd);
+    pkg_name = _get_pkgname(menu_info);
+
+    PERF("get package information & modify bundle done");
+
+    {
+        pid = fork();
+        if (pid == 0) {
+            PERF("fork done");
+            _E("lock up test log(no error) : fork done");
+
+            close(clifd);
+            close(main_fd);
+            __signal_unset_sigchld();
+            __signal_fini();
+
+            snprintf(sock_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, getpid());
+            unlink(sock_path);
+
+            PERF("prepare exec - first done");
+            _E("lock up test log(no error) : prepare exec - first done");
+
+            if (__prepare_exec(pkg_name, app_path,
+                               menu_info, kb) < 0)
+            {
+                _E("preparing work fail to launch - "
+                   "can not launch %s\n", pkg_name);
+                exit(-1);
+            }
+
+            PERF("prepare exec - second done");
+            _E("lock up test log(no error) : prepare exec - second done");
+
+            __real_launch(app_path, kb);
+
+            exit(-1);
+        }
+        _D("==> real launch pid : %d %s\n", pid, app_path);
+        is_real_launch = 1;
+    }
+
+end:
+    __send_result_to_caller(clifd, pid);
+
+    if (pid > 0) {
+        if (is_real_launch) {
+            /*TODO: retry*/
+            __signal_block_sigchld();
+            __send_app_launch_signal(pid);
+            __signal_unblock_sigchld();
+        }
+    }
+
+    if (menu_info != NULL) {
+        _free_app_info_from_db(menu_info);
+    }
+
+    if (kb != NULL) {
+        bundle_free(kb);
+    }
+    if (pkt != NULL) {
+        free(pkt);
+    }
+
+    /* Active Flusing for Daemon */
+    if (initialized > AUL_POLL_CNT) {
+        sqlite3_release_memory(SQLITE_FLUSH_MAX);
+        malloc_trim(0);
+        initialized = 1;
+    }
 }
 
 _static_ int __launchpad_pre_init(int argc, char **argv)
 {
-       int fd;
+    int fd;
 
-       /* signal init*/
-       __signal_init();
+    /* signal init*/
+    __signal_init();
 
-       /* get my(launchpad) command line*/
-       launchpad_cmdline = __proc_get_cmdline_bypid(getpid());
-       if (launchpad_cmdline == NULL) {
-               _E("launchpad cmdline fail to get");
-               return -1;
-       }
-       _D("launchpad cmdline = %s", launchpad_cmdline);
+    /* get my(launchpad) command line*/
+    launchpad_cmdline = __proc_get_cmdline_bypid(getpid());
+    if (launchpad_cmdline == NULL) {
+        _E("launchpad cmdline fail to get");
+        return -1;
+    }
+    _D("launchpad cmdline = %s", launchpad_cmdline);
 
-       /* create launchpad sock        */
-       fd = __create_server_sock(WRT_LAUNCHPAD_PID);
-       if (fd < 0) {
-               _E("server sock error");
-               return -1;
-       }
+    /* create launchpad sock        */
+    fd = __create_server_sock(WRT_LAUNCHPAD_PID);
+    if (fd < 0) {
+        _E("server sock error");
+        return -1;
+    }
 
-       __preload_init(argc, argv);
+    __preload_init(argc, argv);
 
     __preload_init_for_wrt();
 
-       __preexec_init(argc, argv);
+    __preexec_init(argc, argv);
 
-       return fd;
+    return fd;
 }
 
 _static_ int __launchpad_post_init()
 {
-       /* Setting this as a global variable to keep track 
-       of launchpad poll cnt */
-       /* static int initialized = 0;*/
+    /* Setting this as a global variable to keep track
+     * of launchpad poll cnt */
+    /* static int initialized = 0;*/
 
-       if (initialized) {
-               initialized++;
-               return 0;
-       }
+    if (initialized) {
+        initialized++;
+        return 0;
+    }
 
-       if (__signal_set_sigchld() < 0)
-               return -1;
+    if (__signal_set_sigchld() < 0) {
+        return -1;
+    }
 
-       initialized++;
+    initialized++;
 
-       return 0;
+    return 0;
 }
 
 int main(int argc, char **argv)
 {
-       int main_fd;
-       struct pollfd pfds[POLLFD_MAX];
-       int i;
-
-       /* init without concerning X & EFL*/
-       main_fd = __launchpad_pre_init(argc, argv);
-       if (main_fd < 0) {
-               _E("launchpad pre init failed");
-               exit(-1);
-       }
-
-       pfds[0].fd = main_fd;
-       pfds[0].events = POLLIN;
-       pfds[0].revents = 0;
-
-       while (1) {
-               if (poll(pfds, POLLFD_MAX, -1) < 0)
-                       continue;
-
-               /* init with concerning X & EFL (because of booting 
-               sequence problem)*/
-               if (__launchpad_post_init() < 0) {
-                       _E("launcpad post init failed");
-                       exit(-1);
-               }
-
-               for (i = 0; i < POLLFD_MAX; i++) {
-                       if ((pfds[i].revents & POLLIN) != 0) {
-                               __launchpad_main_loop(pfds[i].fd);
-                       }
-               }
-       }
+    int main_fd;
+    struct pollfd pfds[POLLFD_MAX];
+    int i;
+
+    /* init without concerning X & EFL*/
+    main_fd = __launchpad_pre_init(argc, argv);
+    if (main_fd < 0) {
+        _E("launchpad pre init failed");
+        exit(-1);
+    }
+
+    pfds[0].fd = main_fd;
+    pfds[0].events = POLLIN;
+    pfds[0].revents = 0;
+
+    while (1) {
+        if (poll(pfds, POLLFD_MAX, -1) < 0) {
+            continue;
+        }
+
+        /* init with concerning X & EFL (because of booting
+         * sequence problem)*/
+        if (__launchpad_post_init() < 0) {
+            _E("launcpad post init failed");
+            exit(-1);
+        }
+
+        for (i = 0; i < POLLFD_MAX; i++) {
+            if ((pfds[i].revents & POLLIN) != 0) {
+                __launchpad_main_loop(pfds[i].fd);
+            }
+        }
+    }
 }
 
index b9d35fb..6d30b65 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #include <pthread.h>
 #include "app_signal.h"
 
@@ -24,230 +23,243 @@ sigset_t oldmask;
 
 static inline void __socket_garbage_collector()
 {
-       DIR *dp;
-       struct dirent *dentry;
-       char tmp[MAX_LOCAL_BUFSZ];
-
-       dp = opendir(AUL_SOCK_PREFIX);
-       if (dp == NULL)
-               return;
-
-       while ((dentry = readdir(dp)) != NULL) {
-               if (!isdigit(dentry->d_name[0]))
-                       continue;
-
-               snprintf(tmp, MAX_LOCAL_BUFSZ, "/proc/%s", dentry->d_name);
-               if (access(tmp, F_OK) < 0) {    /* Flawfinder: ignore */
-                       snprintf(tmp, MAX_LOCAL_BUFSZ, "%s/%s", AUL_SOCK_PREFIX,
-                                dentry->d_name);
-                       unlink(tmp);
-                       continue;
-               }
-       }
-       closedir(dp);
+    DIR *dp;
+    struct dirent dentry;
+    struct dirent *result;
+    char tmp[MAX_LOCAL_BUFSZ];
+
+    dp = opendir(AUL_SOCK_PREFIX);
+    if (dp == NULL) {
+        return;
+    }
+
+    while (readdir_r(dp, &dentry, &result) == 0 && result != NULL) {
+        if (!isdigit(dentry.d_name[0])) {
+            continue;
+        }
+
+        snprintf(tmp, MAX_LOCAL_BUFSZ, "/proc/%s", dentry.d_name);
+        if (access(tmp, F_OK) < 0) {            /* Flawfinder: ignore */
+            snprintf(tmp, MAX_LOCAL_BUFSZ, "%s/%s", AUL_SOCK_PREFIX,
+                    dentry.d_name);
+            unlink(tmp);
+            continue;
+        }
+    }
+    closedir(dp);
 }
 
 static inline int __send_app_dead_signal(int dead_pid)
 {
-       DBusMessage *message;
+    DBusMessage *message;
 
-       if (bus == NULL)
-               return -1;
+    if (bus == NULL) {
+        return -1;
+    }
 
-       message = dbus_message_new_signal(AUL_DBUS_PATH,
-                                         AUL_DBUS_SIGNAL_INTERFACE,
-                                         AUL_DBUS_APPDEAD_SIGNAL);
+    message = dbus_message_new_signal(AUL_DBUS_PATH,
+                                      AUL_DBUS_SIGNAL_INTERFACE,
+                                      AUL_DBUS_APPDEAD_SIGNAL);
 
-       if (dbus_message_append_args(message,
-                                    DBUS_TYPE_UINT32, &dead_pid,
-                                    DBUS_TYPE_INVALID) == FALSE) {
-               _E("Failed to load data error");
-               return -1;
-       }
+    if (dbus_message_append_args(message,
+                                 DBUS_TYPE_UINT32, &dead_pid,
+                                 DBUS_TYPE_INVALID) == FALSE)
+    {
+        _E("Failed to load data error");
+        return -1;
+    }
 
-       if (dbus_connection_send(bus, message, NULL) == FALSE) {
-               _E("dbus send error");
-               return -1;
-       }
+    if (dbus_connection_send(bus, message, NULL) == FALSE) {
+        _E("dbus send error");
+        return -1;
+    }
 
-       dbus_connection_flush(bus);
-       dbus_message_unref(message);
+    dbus_connection_flush(bus);
+    dbus_message_unref(message);
 
-       _D("send dead signal done\n");
+    _D("send dead signal done\n");
 
-       return 0;
+    return 0;
 }
 
 static inline int __send_app_launch_signal(int launch_pid)
 {
-       DBusMessage *message;
+    DBusMessage *message;
 
-       if (bus == NULL)
-               return -1;
+    if (bus == NULL) {
+        return -1;
+    }
 
-       message = dbus_message_new_signal(AUL_DBUS_PATH,
-                                         AUL_DBUS_SIGNAL_INTERFACE,
-                                         AUL_DBUS_APPLAUNCH_SIGNAL);
+    message = dbus_message_new_signal(AUL_DBUS_PATH,
+                                      AUL_DBUS_SIGNAL_INTERFACE,
+                                      AUL_DBUS_APPLAUNCH_SIGNAL);
 
-       if (dbus_message_append_args(message,
-                                    DBUS_TYPE_UINT32, &launch_pid,
-                                    DBUS_TYPE_INVALID) == FALSE) {
-               _E("Failed to load data error");
-               return -1;
-       }
+    if (dbus_message_append_args(message,
+                                 DBUS_TYPE_UINT32, &launch_pid,
+                                 DBUS_TYPE_INVALID) == FALSE)
+    {
+        _E("Failed to load data error");
+        return -1;
+    }
 
-       if (dbus_connection_send(bus, message, NULL) == FALSE) {
-               _E("dbus send error");
-               return -1;
-       }
+    if (dbus_connection_send(bus, message, NULL) == FALSE) {
+        _E("dbus send error");
+        return -1;
+    }
 
-       dbus_connection_flush(bus);
-       dbus_message_unref(message);
+    dbus_connection_flush(bus);
+    dbus_message_unref(message);
 
-       _D("send launch signal done\n");
+    _D("send launch signal done\n");
 
-       return 0;
+    return 0;
 }
 
 static int __sigchild_action(void *data)
 {
-       pid_t dead_pid;
-       char buf[MAX_LOCAL_BUFSZ];
+    pid_t dead_pid;
+    char buf[MAX_LOCAL_BUFSZ];
 
-       dead_pid = (pid_t) data;
-       if (dead_pid <= 0)
-               goto end;
+    dead_pid = (pid_t) data;
+    if (dead_pid <= 0) {
+        goto end;
+    }
 
-       __send_app_dead_signal(dead_pid);
+    __send_app_dead_signal(dead_pid);
 
-       snprintf(buf, MAX_LOCAL_BUFSZ, "%s/%d", AUL_SOCK_PREFIX, dead_pid);
-       unlink(buf);
+    snprintf(buf, MAX_LOCAL_BUFSZ, "%s/%d", AUL_SOCK_PREFIX, dead_pid);
+    unlink(buf);
 
-       __socket_garbage_collector();
- end:
-       return 0;
+    __socket_garbage_collector();
+end:
+    return 0;
 }
 
 static void __launchpad_sig_child(int signo, siginfo_t *info, void *data)
 {
-       int status;
-       pid_t child_pid;
-       pid_t child_pgid;
+    int status;
+    pid_t child_pid;
+    pid_t child_pgid;
 
-        // warning: unused parameter
-        signo = signo;
-        data = data;
+    // warning: unused parameter
+    (void)signo;
+    (void)data;
 
-       child_pgid = getpgid(info->si_pid);
-       _D("dead_pid = %d pgid = %d", info->si_pid, child_pgid);
+    child_pgid = getpgid(info->si_pid);
+    _D("dead_pid = %d pgid = %d", info->si_pid, child_pgid);
 
-       while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
-               if (child_pid == child_pgid)
-                       killpg(child_pgid, SIGKILL);
-               __sigchild_action((void *)child_pid);
-       }
+    while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
+        if (child_pid == child_pgid) {
+            killpg(child_pgid, SIGKILL);
+        }
+        __sigchild_action((void *)child_pid);
+    }
 
-       return;
+    return;
 }
 
 static inline int __signal_init(void)
 {
-       int i;
-       for (i = 0; i < _NSIG; i++) {
-               switch (i) {
-                       /* controlled by sys-assert package*/
-               case SIGQUIT:
-               case SIGILL:
-               case SIGABRT:
-               case SIGBUS:
-               case SIGFPE:
-               case SIGSEGV:
-               case SIGPIPE:
-                       break;
-               default:
-                       signal(i, SIG_DFL);
-                       break;
-               }
-       }
-
-       return 0;
+    int i;
+    for (i = 0; i < _NSIG; i++) {
+        switch (i) {
+        /* controlled by sys-assert package*/
+        case SIGQUIT:
+        case SIGILL:
+        case SIGABRT:
+        case SIGBUS:
+        case SIGFPE:
+        case SIGSEGV:
+        case SIGPIPE:
+            break;
+        default:
+            signal(i, SIG_DFL);
+            break;
+        }
+    }
+
+    return 0;
 }
 
 static inline int __signal_set_sigchld(void)
 {
-       struct sigaction act;
-       DBusError error;
-
-       dbus_error_init(&error);
-       dbus_threads_init_default();
-       bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
-       if (!bus) {
-               _E("Failed to connect to the D-BUS daemon: %s", error.message);
-               dbus_error_free(&error);
-               return -1;
-       }
-       /* TODO: if process stop mechanism is included, 
-       should be modified (SA_NOCLDSTOP)*/
-       act.sa_handler = NULL;
-       act.sa_sigaction = __launchpad_sig_child;
-       sigemptyset(&act.sa_mask);
-       act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
-
-       if (sigaction(SIGCHLD, &act, &old_sigchild) < 0)
-               return -1;
-
-       return 0;
+    struct sigaction act;
+    DBusError error;
+
+    dbus_error_init(&error);
+    dbus_threads_init_default();
+    bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
+    if (!bus) {
+        _E("Failed to connect to the D-BUS daemon: %s", error.message);
+        dbus_error_free(&error);
+        return -1;
+    }
+    /* TODO: if process stop mechanism is included,
+     * should be modified (SA_NOCLDSTOP)*/
+    act.sa_handler = NULL;
+    act.sa_sigaction = __launchpad_sig_child;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
+
+    if (sigaction(SIGCHLD, &act, &old_sigchild) < 0) {
+        return -1;
+    }
+
+    return 0;
 }
 
 static inline int __signal_unset_sigchld(void)
 {
-       struct sigaction dummy;
+    struct sigaction dummy;
 
-       if (bus == NULL)
-               return 0;
+    if (bus == NULL) {
+        return 0;
+    }
 
-       dbus_connection_close(bus);
-       if (sigaction(SIGCHLD, &old_sigchild, &dummy) < 0)
-               return -1;
+    dbus_connection_close(bus);
+    if (sigaction(SIGCHLD, &old_sigchild, &dummy) < 0) {
+        return -1;
+    }
 
-       return 0;
+    return 0;
 }
 
 static inline int __signal_block_sigchld(void)
 {
-       sigset_t newmask;
+    sigset_t newmask;
 
-       sigemptyset(&newmask);
-       sigaddset(&newmask, SIGCHLD);
+    sigemptyset(&newmask);
+    sigaddset(&newmask, SIGCHLD);
 
-       if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) {
-               _E("SIG_BLOCK error");
-               return -1;
-       }
+    if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) {
+        _E("SIG_BLOCK error");
+        return -1;
+    }
 
-       _D("SIGCHLD blocked");
+    _D("SIGCHLD blocked");
 
-       return 0;
+    return 0;
 }
 
 static inline int __signal_unblock_sigchld(void)
 {
-       if(sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) {
-               _E("SIG_SETMASK error");
-               return -1;
-       }
+    if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) {
+        _E("SIG_SETMASK error");
+        return -1;
+    }
 
-       _D("SIGCHLD unblocked");
-       return 0;
+    _D("SIGCHLD unblocked");
+    return 0;
 }
 
 static inline int __signal_fini(void)
 {
 #ifndef PRELOAD_ACTIVATE
-       int i;
-       for (i = 0; i < _NSIG; i++)
-               signal(i, SIG_DFL);
+    int i;
+    for (i = 0; i < _NSIG; i++) {
+        signal(i, SIG_DFL);
+    }
 #endif
-       return 0;
+    return 0;
 }
 
index b871dae..678434c 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -27,8 +26,7 @@
 #include "simple_util.h"
 
 static Atom a_pid;
-static int (*x_old_error) (Display *, XErrorEvent *);
-
+static int (*x_old_error)(Display *, XErrorEvent *);
 
 static pid_t __get_win_pid(Display *d, Window win);
 static int __find_win(Display *d, Window *win, pid_t pid);
@@ -37,162 +35,175 @@ static int __cb_x_error(Display *disp, XErrorEvent *ev);
 
 static pid_t __get_win_pid(Display *d, Window win)
 {
-       int r;
-       pid_t pid;
+    int r;
+    pid_t pid;
 
-       Atom a_type;
-       int format;
-       unsigned long nitems;
-       unsigned long bytes_after;
-       unsigned char *prop_ret;
+    Atom a_type;
+    int format;
+    unsigned long nitems;
+    unsigned long bytes_after;
+    unsigned char *prop_ret;
 
-       retv_if(d == NULL || !a_pid, -1);
+    retv_if(d == NULL || !a_pid, -1);
 
-       prop_ret = NULL;
-       r = XGetWindowProperty(d, win, a_pid, 0, 1, False, XA_CARDINAL,
-                       &a_type, &format, &nitems, &bytes_after, &prop_ret);
-       if (r != Success || prop_ret == NULL)
-               return -1;
+    prop_ret = NULL;
+    r = XGetWindowProperty(d, win, a_pid, 0, 1, False, XA_CARDINAL,
+                           &a_type, &format, &nitems, &bytes_after, &prop_ret);
+    if (r != Success || prop_ret == NULL) {
+        return -1;
+    }
 
-       if (a_type == XA_CARDINAL && format == 32)
-               pid = *(unsigned long *)prop_ret;
-       else
-               pid = -1;
+    if (a_type == XA_CARDINAL && format == 32) {
+        pid = *(unsigned long *)prop_ret;
+    } else {
+        pid = -1;
+    }
 
-       XFree(prop_ret);
+    XFree(prop_ret);
 
-       return pid;
+    return pid;
 }
 
 static int __find_win(Display *d, Window *win, pid_t pid)
 {
-       int r;
-       pid_t p;
-       unsigned int n;
-       Window root, parent, *child;
-
-       p = __get_win_pid(d, *win);
-       if (p == pid)
-               return 1;
-
-       r = XQueryTree(d, *win, &root, &parent, &child, &n);
-       if (r) {
-               int i;
-               int found = 0;
-
-               for (i = 0; i < n; i++) {
-                       found = __find_win(d, &child[i], pid);
-                       if (found) {
-                               *win = child[i];
-                               break;
-                       }
-               }
-               XFree(child);
-
-               if (found)
-                       return 1;
-       }
-
-       return 0;
+    int r;
+    pid_t p;
+    unsigned int n;
+    Window root, parent, *child;
+
+    p = __get_win_pid(d, *win);
+    if (p == pid) {
+        return 1;
+    }
+
+    r = XQueryTree(d, *win, &root, &parent, &child, &n);
+    if (r) {
+        unsigned int i;
+        int found = 0;
+
+        for (i = 0; i < n; i++) {
+            found = __find_win(d, &child[i], pid);
+            if (found) {
+                *win = child[i];
+                break;
+            }
+        }
+        XFree(child);
+
+        if (found) {
+            return 1;
+        }
+    }
+
+    return 0;
 }
 
 static int __raise_win(Display *d, Window win)
 {
-       XWindowAttributes attr;
-       attr.map_state = IsUnmapped;
+    XWindowAttributes attr;
+    attr.map_state = IsUnmapped;
 
-       XMapRaised(d, win);
+    XMapRaised(d, win);
 
-       XGetWindowAttributes(d, win, &attr);
+    XGetWindowAttributes(d, win, &attr);
 
-       if (attr.map_state == IsUnmapped)
-               _D("unmapped");
-       else if (attr.map_state == IsUnviewable)
-               _D("unviewable");
-       else if (attr.map_state == IsViewable)
-               _D("viewable");
+    if (attr.map_state == IsUnmapped) {
+        _D("unmapped");
+    } else if (attr.map_state == IsUnviewable) {
+        _D("unviewable");
+    } else if (attr.map_state == IsViewable) {
+        _D("viewable");
+    }
 
-       retv_if(attr.map_state != IsViewable, -1);
+    retv_if(attr.map_state != IsViewable, -1);
 
-       XSetInputFocus(d, win, RevertToPointerRoot, CurrentTime);
+    XSetInputFocus(d, win, RevertToPointerRoot, CurrentTime);
 
-       return 0;
+    return 0;
 }
 
 int x_util_raise_win(pid_t pid)
 {
-       int r;
-       int found;
-       Display *d;
-       Window win;
+    int r;
+    int found;
+    Display *d;
+    Window win;
 
-       if (pid < 1)
-               return -1;
+    if (pid < 1) {
+        return -1;
+    }
 
-       r = kill(pid, 0);
-       if (r == -1)
-               return -1;
+    r = kill(pid, 0);
+    if (r == -1) {
+        return -1;
+    }
 
-       d = XOpenDisplay(NULL);
-       retv_if(d == NULL, -1);
+    d = XOpenDisplay(NULL);
+    retv_if(d == NULL, -1);
 
-       win = XDefaultRootWindow(d);
+    win = XDefaultRootWindow(d);
 
-       if (!a_pid)
-               a_pid = XInternAtom(d, "X_CLIENT_PID", True);
+    if (!a_pid) {
+        a_pid = XInternAtom(d, "X_CLIENT_PID", True);
+    }
 
-       found = __find_win(d, &win, pid);
-       if (!found) {
-               XCloseDisplay(d);
-               _E("cannot found window with pid - %d", pid);
-               return -1;
-       }
+    found = __find_win(d, &win, pid);
+    if (!found) {
+        XCloseDisplay(d);
+        _E("cannot found window with pid - %d", pid);
+        return -1;
+    }
 
-       r = __raise_win(d, win);
-       if (r < 0)
-               _E("fail to raise win");
+    r = __raise_win(d, win);
+    if (r < 0) {
+        _E("fail to raise win");
+    }
 
-       XCloseDisplay(d);
+    XCloseDisplay(d);
 
-       return r;
+    return r;
 }
 
 int x_util_get_default_size(double *w, double *h)
 {
-       Display *d;
-       int screen_num;
+    Display *d;
+    int screen_num;
 
-       d = XOpenDisplay(NULL);
-       if (d == NULL)
-               return -1;
+    d = XOpenDisplay(NULL);
+    if (d == NULL) {
+        return -1;
+    }
 
-       screen_num = DefaultScreen(d);
+    screen_num = DefaultScreen(d);
 
-       *w = DisplayWidth(d, screen_num);
-       *h = DisplayHeight(d, screen_num);
+    *w = DisplayWidth(d, screen_num);
+    *h = DisplayHeight(d, screen_num);
 
-       _D("Root Width = %lf, Height = %lf\n", *w, *h);
+    _D("Root Width = %lf, Height = %lf\n", *w, *h);
 
-       XCloseDisplay(d);
+    XCloseDisplay(d);
 
-       return 0;
+    return 0;
 }
 
-static int __cb_x_error(Display *disp, XErrorEvent *ev)
+static int __cb_x_error(Displaydisp, XErrorEvent *ev)
 {
-       _E("X error received - Error Code = %d", ev->error_code);
-       return 0;
+    //warning unused parameter
+    (void)disp;
+
+    _E("X error received - Error Code = %d", ev->error_code);
+    return 0;
 }
 
 int x_util_init()
 {
-       x_old_error = XSetErrorHandler(__cb_x_error);
-       return 0;
+    x_old_error = XSetErrorHandler(__cb_x_error);
+    return 0;
 }
 
 int x_util_fini()
 {
-       XSetErrorHandler(x_old_error);
-       return 0;
+    XSetErrorHandler(x_old_error);
+    return 0;
 }
 
index 21c27bc..7c13032 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #ifndef __UTIL_X_H_
 #define __UTIL_X_H_
 
index 313aa2a..a2da81b 100644 (file)
  *    limitations under the License.
  */
 
-
-#ifdef PRELOAD_ACTIVATE 
+#ifdef PRELOAD_ACTIVATE
 
 #include <dlfcn.h>
-#define PRELOAD_FILE        SHARE_PREFIX"/preload_list.txt"
-#define PRELOAD_FILE_WRT    SHARE_PREFIX"/preload_list_wrt.txt"
+#include <glib.h>
+
+#define PRELOAD_FILE        SHARE_PREFIX "/preload_list.txt"
+#define PRELOAD_FILE_WRT    SHARE_PREFIX "/preload_list_wrt.txt"
 
-#define EFL_PREINIT_FUNC       "elm_quicklaunch_init"
-#define EFL_SHUTDOWN_FUNC      "elm_quicklaunch_shutdown"
+#define EFL_PREINIT_FUNC    "elm_quicklaunch_init"
+#define EFL_SHUTDOWN_FUNC   "elm_quicklaunch_shutdown"
 
 static int preload_initialized = 0;
 static int g_argc;
 static char **g_argv;
 static size_t max_cmdline_size = 0;
 
-static int (*dl_einit) () = NULL;
-static int (*dl_efini) () = NULL;
+static GSList *g_dlopen_handle_list = NULL;
+
+typedef struct handle_list_t {
+    int (*dl_einit)();
+    int (*dl_efini)();
+    void *handle;
+} handle_list_t;
 
 static inline void __preload_init(int argc, char **argv)
 {
-       void *handle = NULL;
-       char soname[MAX_LOCAL_BUFSZ] = {0, };
-       FILE *preload_list;
-       int (*func)() = NULL;
-       int i;
-
-       g_argc = argc;
-       g_argv = argv;
-       for (i = 0; i < argc; i++) {
-               max_cmdline_size += (strlen(argv[i]) + 1);
-       }
-       _D("max_cmdline_size = %d", max_cmdline_size);
-
-       preload_list = fopen(PRELOAD_FILE, "rt");
-       if (preload_list == NULL) {
-               _E("no preload\n");
-               return;
-       }
-
-       while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > (char*)0) {
-               soname[MAX_LOCAL_BUFSZ-1] = 0;
-               handle = dlopen(soname, RTLD_NOW);
-               if (handle == NULL)
-                       continue;
-               _D("preload %s# - handle : %x\n", soname, handle);
-
-               func = dlsym(handle, EFL_PREINIT_FUNC);
-               if (func != NULL) {
-                       _D("get pre-initialization function\n");
-                       dl_einit = func;
-                       func = dlsym(handle, EFL_SHUTDOWN_FUNC);
-                       if (func != NULL) {
-                               _D("get shutdown function\n");
-                               dl_efini = func;
-                       }
-               }
-       }
-
-       fclose(preload_list);
-       preload_initialized = 1;
+    char soname[MAX_LOCAL_BUFSZ] = { 0, };
+    FILE *preload_list;
+    int (*func)() = NULL;
+    int i;
+
+    g_argc = argc;
+    g_argv = argv;
+    for (i = 0; i < argc; i++) {
+        max_cmdline_size += (strlen(argv[i]) + 1);
+    }
+    _D("max_cmdline_size = %d", max_cmdline_size);
+
+    preload_list = fopen(PRELOAD_FILE, "rt");
+    if (preload_list == NULL) {
+        _E("no preload\n");
+        return;
+    }
+
+    while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) != NULL) {
+        size_t pos = strnlen(soname, MAX_LOCAL_BUFSZ);
+        if (pos > 0) {
+            soname[pos - 1] = '\0';
+        }
+
+        handle_list_t *entry = calloc(1, sizeof(handle_list_t));
+        if (!entry) {
+            _E("out of memory\n");
+            break;
+        }
+
+        entry->handle = dlopen(soname, RTLD_NOW);
+        if (entry->handle == NULL) {
+            free(entry);
+            continue;
+        }
+        _D("preload %s# - handle : %x\n", soname, entry->handle);
+
+        func = dlsym(entry->handle, EFL_PREINIT_FUNC);
+        if (func != NULL) {
+            _D("get pre-initialization function\n");
+            entry->dl_einit = func;
+            func = dlsym(entry->handle, EFL_SHUTDOWN_FUNC);
+            if (func != NULL) {
+                _D("get shutdown function\n");
+                entry->dl_efini = func;
+            }
+        }
+        g_dlopen_handle_list = g_slist_prepend(g_dlopen_handle_list, entry);
+    }
+    fclose(preload_list);
+    preload_initialized = 1;
 }
 
 static inline int preinit_init()
 {
-       if (dl_einit != NULL)
-               dl_einit(0, NULL);
-       _D("pre-initialzation on");
-       return 0;
+    GSList *iter = NULL;
+    handle_list_t *entry;
+
+    for (iter = g_dlopen_handle_list; iter != NULL; iter = g_slist_next(iter)) {
+        entry = iter->data;
+        if (entry->dl_einit != NULL)
+            entry->dl_einit(0, NULL);
+    }
+    _D("pre-initialzation on");
+    return 0;
 }
 
 static inline int preinit_fini()
 {
-       if (dl_efini != NULL)
-               dl_efini();
-       _D("pre-initialization off");
-       return 0;
+    GSList *iter = NULL;
+    handle_list_t *entry;
+
+    for (iter = g_dlopen_handle_list; iter != NULL; iter = g_slist_next(iter)) {
+        entry = iter->data;
+        if (entry->dl_efini != NULL)
+            entry->dl_efini();
+        if (entry->handle)
+            dlclose(entry->handle);
+    }
+    _D("pre-initialization off");
+    g_slist_free_full(g_dlopen_handle_list, free);
+    g_dlopen_handle_list = NULL;
+    return 0;
 }
 
 /* TODO : how to set cmdline gracefully ?? */
 static inline int __change_cmdline(char *cmdline)
 {
-       if (strlen(cmdline) > max_cmdline_size + 1) {
-               _E("cmdline exceed max size : %d", max_cmdline_size);
-               return -1;
-       }
+    if (strlen(cmdline) > max_cmdline_size + 1) {
+        _E("cmdline exceed max size : %d", max_cmdline_size);
+        return -1;
+    }
 
-       memset(g_argv[0], '\0', max_cmdline_size);
-       snprintf(g_argv[0], max_cmdline_size, "%s", cmdline);
+    memset(g_argv[0], '\0', max_cmdline_size);
+    snprintf(g_argv[0], max_cmdline_size, "%s", cmdline);
 
-       return 0;
+    return 0;
 }
 
 static inline void __preload_exec(int argc, char **argv)
 {
-       void *handle = NULL;
-       int (*dl_main) (int, char **);
+    void *handle = NULL;
+    int (*dl_main)(int, char **);
 
-       if (!preload_initialized)
-               return;
+    if (!preload_initialized) {
+        return;
+    }
 
-       handle = dlopen(argv[0], RTLD_LAZY | RTLD_GLOBAL);
-       if (handle == NULL) {
-               return;
-       }
+    handle = dlopen(argv[0], RTLD_LAZY | RTLD_GLOBAL);
+    if (handle == NULL) {
+        return;
+    }
 
-       dl_main = dlsym(handle, "main");
-       if (dl_main != NULL) {
+    dl_main = dlsym(handle, "main");
+    if (dl_main != NULL) {
 #ifndef NATIVE_LAUNCHPAD
         /* do nothing */
 #else
-               if (__change_cmdline(argv[0]) < 0) {
-                       _E("change cmdline fail");
-                       return;
-               }
+        if (__change_cmdline(argv[0]) < 0) {
+            _E("change cmdline fail");
+            return;
+        }
 #endif
-               dl_main(argc, argv);
-       } else {
-               _E("dlsym not founded. bad preloaded app - check fpie pie");
-       }
+        dl_main(argc, argv);
+    } else {
+        _E("dlsym not founded. bad preloaded app - check fpie pie");
+    }
 
-       exit(0);
+    exit(0);
+}
+
+static int g_wrt_dlopen_size = 5;
+static int g_wrt_dlopen_count = 0;
+static void** g_wrt_dlopen_handle_list = NULL;
+
+static inline int __preload_save_dlopen_handle(void *handle)
+{
+    if (!handle) {
+        return 1;
+    }
+    if (g_wrt_dlopen_count == g_wrt_dlopen_size || !g_wrt_dlopen_handle_list) {
+        void** tmp =
+            realloc(g_wrt_dlopen_handle_list, 2 * g_wrt_dlopen_size * sizeof(void *));
+        if (NULL == tmp) {
+            _E("out of memory\n");
+            dlclose(handle);
+            return 1;
+        }
+        g_wrt_dlopen_size *= 2;
+        g_wrt_dlopen_handle_list = tmp;
+    }
+    g_wrt_dlopen_handle_list[g_wrt_dlopen_count++] = handle;
+    return 0;
+}
+
+static inline void __preload_fini_for_wrt()
+{
+    int i = 0;
+    if (!g_wrt_dlopen_handle_list) {
+        return;
+    }
+    for (i = 0; i < g_wrt_dlopen_count; ++i)
+    {
+        void *handle = g_wrt_dlopen_handle_list[i];
+        if (handle) {
+            if (0 != dlclose(handle)) {
+                _E("dlclose failed\n");
+            }
+        }
+    }
+    free(g_wrt_dlopen_handle_list);
+    g_wrt_dlopen_handle_list = NULL;
+    g_wrt_dlopen_size = 5;
+    g_wrt_dlopen_count = 0;
 }
 
 static inline void __preload_init_for_wrt()
 {
-       void *handle = NULL;
-       char soname[MAX_LOCAL_BUFSZ];
-       FILE *preload_list;
-
-       preload_list = fopen(PRELOAD_FILE_WRT, "rt");
-       if (preload_list == NULL) {
-               _E("no wrt preload\n");
-               return;
-       }
-
-       while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > (char*)0) {
-               soname[strlen(soname) - 1] = 0;
-        handle = dlopen((const char *)soname, RTLD_NOW|RTLD_GLOBAL);
-               if (handle == NULL)
-                       continue;
-               _D("preload %s# - handle : %x\n", soname, handle);
-       }
-
-       fclose(preload_list);
+    if (0 != atexit(__preload_fini_for_wrt)) {
+        _E("Cannot register atexit callback. Libraries will not be unloaded");
+    }
+    void *handle = NULL;
+    char soname[MAX_LOCAL_BUFSZ];
+    FILE *preload_list;
+
+    preload_list = fopen(PRELOAD_FILE_WRT, "rt");
+    if (preload_list == NULL) {
+        _E("no wrt preload\n");
+        return;
+    }
+
+    while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) != NULL) {
+        size_t len = strnlen(soname, MAX_LOCAL_BUFSZ);
+        if (len > 0) {
+            soname[len - 1] = '\0';
+        }
+        handle = dlopen(soname, RTLD_NOW | RTLD_GLOBAL);
+        if (handle == NULL) {
+            continue;
+        }
+        if (0 != __preload_save_dlopen_handle(handle)) {
+            _E("Cannot save handle, no more preloads");
+            break;
+        }
+        _D("preload %s# - handle : %x\n", soname, handle);
+    }
+
+    fclose(preload_list);
 }
 
 #else
index 44bb556..26edf9f 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/smack.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <time.h>
+
 
 #include "app_sock.h"
 #include "simple_util.h"
 
-static int __connect_client_sock(int sockfd, const struct sockaddr *saptr, socklen_t salen,
-                  int nsec);
-
+static int __connect_client_sock(int sockfd,
+                                 const struct sockaddr *saptr,
+                                 socklen_t salen,
+                                 int nsec);
 
-static inline void __set_sock_option(int fd, int cli)
+static inline int __set_sock_option(int fd, int cli)
 {
-       int size;
-       struct timeval tv = { 3, 200 * 1000 };  /*  3.2 sec */
-
-       size = AUL_SOCK_MAXBUFF;
-       setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
-       setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
-       if (cli)
-               setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+    int size;
+    struct timeval tv = { 3, 200 * 1000 };    /*  3.2 sec */
+
+    size = AUL_SOCK_MAXBUFF;
+    if (0 != setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) ||
+        0 != setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)))
+    {
+        return 1;
+    }
+    if (cli && 0 != setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv))) {
+        return 1;
+    }
+    return 0;
 }
 
 int __create_server_sock(int pid)
 {
-       struct sockaddr_un saddr;
-       struct sockaddr_un p_saddr;
-       int fd;
-       mode_t orig_mask;
-
-       /* Create basedir for our sockets */
-       orig_mask = umask(0);
-       (void) mkdir(AUL_SOCK_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
-       umask(orig_mask);
-
-       fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
-       /*  support above version 2.6.27*/
-       if (fd < 0) {
-               if (errno == EINVAL) {
-                       fd = socket(AF_UNIX, SOCK_STREAM, 0);
-                       if (fd < 0) {
-                               _E("second chance - socket create error");
-                               return -1;
-                       }
-               } else {
-                       _E("socket error");
-                       return -1;
-               }
-       }
-
-       bzero(&saddr, sizeof(saddr));
-       saddr.sun_family = AF_UNIX;
-       snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
-       unlink(saddr.sun_path);
-
-       /* labeling to socket for SMACK */
-       if(getuid() == 0) {     // this is meaningful iff current user is ROOT
-               if(smack_fsetlabel(fd, "@", SMACK_LABEL_IPOUT) != 0) {
-                       /* in case of unsupported filesystem on 'socket' */
-                       /* or permission error by using 'emulator', bypass*/
-                       if((errno != EOPNOTSUPP) && (errno != EPERM)) {
-                               _E("labeling to socket(IPOUT) error");
+    struct sockaddr_un saddr;
+    struct sockaddr_un p_saddr;
+    int fd;
+    mode_t orig_mask;
+
+    /* Create basedir for our sockets */
+    orig_mask = umask(0);
+    (void) mkdir(AUL_SOCK_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
+    umask(orig_mask);
+
+    fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+    /*  support above version 2.6.27*/
+    if (fd < 0) {
+        if (errno == EINVAL) {
+            fd = socket(AF_UNIX, SOCK_STREAM, 0);
+            if (fd < 0) {
+                _E("second chance - socket create error");
+                return -1;
+            }
+        } else {
+            _E("socket error");
+            return -1;
+        }
+    }
+
+    memset(&saddr, 0, sizeof(saddr));
+    saddr.sun_family = AF_UNIX;
+    snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
+    unlink(saddr.sun_path);
+
+    /* labeling to socket for SMACK */
+    if (getuid() == 0) {        // this is meaningful iff current user is ROOT
+        if (smack_fsetlabel(fd, "@", SMACK_LABEL_IPOUT) != 0) {
+            /* in case of unsupported filesystem on 'socket' */
+            /* or permission error by using 'emulator', bypass*/
+            if ((errno != EOPNOTSUPP) && (errno != EPERM)) {
+                _E("labeling to socket(IPOUT) error");
                 close(fd);
-                               return -1;
-                       }
-               }
-               if(smack_fsetlabel(fd, "*", SMACK_LABEL_IPIN) != 0) {
-                       /* in case of unsupported filesystem on 'socket' */
-                       /* or permission error by using 'emulator', bypass*/
-                       if((errno != EOPNOTSUPP) && (errno != EPERM)) {
-                               _E("labeling to socket(IPIN) error");
+                return -1;
+            }
+        }
+        if (smack_fsetlabel(fd, "*", SMACK_LABEL_IPIN) != 0) {
+            /* in case of unsupported filesystem on 'socket' */
+            /* or permission error by using 'emulator', bypass*/
+            if ((errno != EOPNOTSUPP) && (errno != EPERM)) {
+                _E("labeling to socket(IPIN) error");
                 close(fd);
-                               return -1;
-                       }
-               }
-       }
+                return -1;
+            }
+        }
+    }
+
+    if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+        _E("bind error");
+        close(fd);
+        return -1;
+    }
 
-       if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
-               _E("bind error");
+    if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+        /* Flawfinder: ignore*/
+        _E("failed to change the socket permission");
         close(fd);
-               return -1;
-       }
+        return -1;
+    }
 
-       if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
-               /* Flawfinder: ignore*/
-               _E("failed to change the socket permission");
+    if (0 != __set_sock_option(fd, 0)) {
         close(fd);
-               return -1;
-       }
-
-       __set_sock_option(fd, 0);
-
-       if (listen(fd, 10) == -1) {
-               _E("listen error");
-               close(fd);
-               return -1;
-       }
-
-       /* support app launched by shell script */
-       if (pid != WRT_LAUNCHPAD_PID) {
-               int pgid;
-               pgid = getpgid(pid);
-               if (pgid > 1) {
-                       snprintf(p_saddr.sun_path, UNIX_PATH_MAX, "%s/%d",
-                                AUL_SOCK_PREFIX, pgid);
-                       if (link(saddr.sun_path, p_saddr.sun_path) < 0) {
-                               if (errno == EEXIST)
-                                       _D("pg path - already exists");
-                               else
-                                       _E("pg path - unknown create error");
-                       }
-               }
-       }
-
-       return fd;
+        return -1;
+    }
+
+    if (listen(fd, 10) == -1) {
+        _E("listen error");
+        close(fd);
+        return -1;
+    }
+
+    /* support app launched by shell script */
+    if (pid != WRT_LAUNCHPAD_PID) {
+        int pgid;
+        pgid = getpgid(pid);
+        if (pgid > 1) {
+            snprintf(p_saddr.sun_path, UNIX_PATH_MAX, "%s/%d",
+                     AUL_SOCK_PREFIX, pgid);
+            if (link(saddr.sun_path, p_saddr.sun_path) < 0) {
+                if (errno == EEXIST) {
+                    _D("pg path - already exists");
+                }
+                else {
+                    _E("pg path - unknown create error");
+                }
+            }
+        }
+    }
+
+    return fd;
 }
 
 int __create_client_sock(int pid)
 {
-       int fd = -1;
-       struct sockaddr_un saddr = { 0, };
-       int retry = 1;
-       int ret = -1;
-
-       fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);    
-       /*  support above version 2.6.27*/
-       if (fd < 0) {
-               if (errno == EINVAL) {
-                       fd = socket(AF_UNIX, SOCK_STREAM, 0);
-                       if (fd < 0) {
-                               _E("second chance - socket create error");
-                               return -1;
-                       }
-               } else {
-                       _E("socket error");
-                       return -1;
-               }
-       }
-
-       saddr.sun_family = AF_UNIX;
-       snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
- retry_con:
-       ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr),
-                       100 * 1000);
-       if (ret < -1) {
-               _E("maybe peer not launched or peer daed\n");
-               if (retry > 0) {
-                       usleep(100 * 1000);
-                       retry--;
-                       goto retry_con;
-               }
-       }
-       if (ret < 0) {
-               close(fd);
-               return -1;
-       }
-
-       __set_sock_option(fd, 1);
-
-       return fd;
+    int fd = -1;
+    struct sockaddr_un saddr;
+    memset(&saddr, 0, sizeof(saddr));
+    int retry = 1;
+    int ret = -1;
+
+    fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+    /*  support above version 2.6.27*/
+    if (fd < 0) {
+        if (errno == EINVAL) {
+            fd = socket(AF_UNIX, SOCK_STREAM, 0);
+            if (fd < 0) {
+                _E("second chance - socket create error");
+                return -1;
+            }
+        } else {
+            _E("socket error");
+            return -1;
+        }
+    }
+
+    saddr.sun_family = AF_UNIX;
+    snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
+
+    while ((ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr),
+            100 * 1000)) < -1) {
+        _E("maybe peer not launched or peer daed\n");
+        if (retry > 0) {
+            struct timespec duration = { 0, 100 * 1000 * 1000 };
+            nanosleep(&duration, NULL);     /* 100ms sleep*/
+            retry--;
+        }
+        else break;
+    }
+
+    if (ret < 0) {
+        close(fd);
+        return -1;
+    }
+
+    if (0 != __set_sock_option(fd, 1)) {
+        close(fd);
+        return -1;
+    }
+
+    return fd;
 }
 
-static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t salen,
-                  int nsec)
+static int __connect_client_sock(int fd,
+                                 const struct sockaddr *saptr,
+                                 socklen_t salen,
+                                 int nsec)
 {
-       int flags;
-       int ret;
-       int error;
-       socklen_t len;
-       fd_set readfds;
-       fd_set writefds;
-       struct timeval timeout;
-
-       flags = fcntl(fd, F_GETFL, 0);
-       fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-
-       error = 0;
-       if ((ret = connect(fd, (struct sockaddr *)saptr, salen)) < 0) {
-               if (errno != EAGAIN && errno != EINPROGRESS) {
-                       fcntl(fd, F_SETFL, flags);      
-                       return (-2);
-               }
-       }
-
-       /* Do whatever we want while the connect is taking place. */
-       if (ret == 0)
-               goto done;      /* connect completed immediately */
-
-       FD_ZERO(&readfds);
-       FD_SET(fd, &readfds);
-       writefds = readfds;
-       timeout.tv_sec = 0;
-       timeout.tv_usec = nsec;
-
-       if ((ret = select(fd + 1, &readfds, &writefds, NULL, 
-                       nsec ? &timeout : NULL)) == 0) {
-               close(fd);      /* timeout */
-               errno = ETIMEDOUT;
-               return (-1);
-       }
-
-       if (FD_ISSET(fd, &readfds) || FD_ISSET(fd, &writefds)) {
-               len = sizeof(error);
-               if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
-                       return (-1);    /* Solaris pending error */
-       } else
-               return (-1);    /* select error: sockfd not set*/
-
- done:
-       (void) fcntl(fd, F_SETFL, flags);
-       if (error) {
-               close(fd);
-               errno = error;
-               return (-1);
-       }
-       return (0);
+    int flags;
+    int ret;
+    int error;
+    socklen_t len;
+    fd_set readfds;
+    fd_set writefds;
+    struct timeval timeout;
+
+    flags = fcntl(fd, F_GETFL, 0);
+    if (0 != fcntl(fd, F_SETFL, flags | O_NONBLOCK)) {
+        return -1;
+    }
+
+    error = 0;
+    if ((ret = connect(fd, (struct sockaddr *)saptr, salen)) < 0) {
+        if (errno != EAGAIN && errno != EINPROGRESS) {
+            (void) fcntl(fd, F_SETFL, flags);
+            return (-2);
+        }
+    }
+
+    /* Do whatever we want while the connect is taking place. */
+    if (ret == 0) {
+        goto done;    /* connect completed immediately */
+    }
+    FD_ZERO(&readfds);
+    FD_SET(fd, &readfds);
+    writefds = readfds;
+    timeout.tv_sec = 0;
+    timeout.tv_usec = nsec;
+
+    if ((ret = select(fd + 1, &readfds, &writefds, NULL,
+                      nsec ? &timeout : NULL)) == 0) {
+        close(fd);    /* timeout */
+        errno = ETIMEDOUT;
+        return (-1);
+    }
+
+    if (FD_ISSET(fd, &readfds) || FD_ISSET(fd, &writefds)) {
+        len = sizeof(error);
+        if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
+            return (-1);    /* Solaris pending error */
+        }
+    }
+    else {
+        return (-1);    /* select error: sockfd not set*/
+    }
+
+done:
+    (void) fcntl(fd, F_SETFL, flags);
+    if (error) {
+        close(fd);
+        errno = error;
+        return (-1);
+    }
+    return (0);
 }
 
 /**
@@ -243,164 +267,176 @@ static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t
  */
 int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
 {
-       int fd;
-       int len;
-       int res = 0;
-       app_pkt_t *pkt = NULL;
-
-       if (kb_data == NULL || datalen > AUL_SOCK_MAXBUFF - 8) {
-               _E("keybundle error\n");
-               return -EINVAL;
-       }
-
-       fd = __create_client_sock(pid);
-       if (fd < 0)
-               return -ECOMM;
-
-       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
-       if (NULL == pkt) {
-               _E("Malloc Failed!");
-               return -ENOMEM;
-       }
-       memset(pkt, 0, AUL_SOCK_MAXBUFF);
-
-       pkt->cmd = cmd;
-       pkt->len = datalen;
-       memcpy(pkt->data, kb_data, datalen);
-
-       if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
-               _E("sendto() failed - %d %d (errno %d)", len, datalen + 8, errno);
-               if (errno == EPIPE) {
-                       _E("pid:%d, fd:%d\n", pid, fd);
-               }
-               close(fd);
-               if (pkt) {
-                       free(pkt);
-                       pkt = NULL;
-               }
-               return -ECOMM;
-       }
-       if (pkt) {
-               free(pkt);
-               pkt = NULL;
-       }
-
-       len = recv(fd, &res, sizeof(int), 0);
-       if (len == -1) {
-               if (errno == EAGAIN) {
-                       _E("recv timeout \n");
-                       res = -EAGAIN;
-               } else {
-                       _E("recv error\n");
-                       res = -ECOMM;
-               }
-       }
-       close(fd);
-
-       return res;
+    int fd;
+    int len;
+    int res = 0;
+    app_pkt_t *pkt = NULL;
+
+    if (kb_data == NULL || datalen > AUL_SOCK_MAXBUFF - 8) {
+        _E("keybundle error\n");
+        return -EINVAL;
+    }
+
+    fd = __create_client_sock(pid);
+    if (fd < 0) {
+        return -ECOMM;
+    }
+
+    pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+    if (NULL == pkt) {
+        _E("Malloc Failed!");
+        return -ENOMEM;
+    }
+    memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+    pkt->cmd = cmd;
+    pkt->len = datalen;
+    memcpy(pkt->data, kb_data, datalen);
+
+    if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
+        _E("sendto() failed - %d %d (errno %d)", len, datalen + 8, errno);
+        if (errno == EPIPE) {
+            _E("pid:%d, fd:%d\n", pid, fd);
+        }
+        close(fd);
+        if (pkt) {
+            free(pkt);
+            pkt = NULL;
+        }
+        return -ECOMM;
+    }
+    if (pkt) {
+        free(pkt);
+        pkt = NULL;
+    }
+
+    len = recv(fd, &res, sizeof(int), 0);
+    if (len == -1) {
+        if (errno == EAGAIN) {
+            _E("recv timeout \n");
+            res = -EAGAIN;
+        } else {
+            _E("recv error\n");
+            res = -ECOMM;
+        }
+    }
+    close(fd);
+
+    return res;
 }
 
 app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
 {
-       int len;
-       struct sockaddr_un aul_addr = { 0, };
-       int sun_size;
-       app_pkt_t *pkt = NULL;
-       int cl = sizeof(struct ucred);
-
-       sun_size = sizeof(struct sockaddr_un);
-
-       if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,
-                            (socklen_t *) &sun_size)) == -1) {
-               if (errno != EINTR)
-                       _E("accept error");
-               return NULL;
-       }
-
-       if (getsockopt(*clifd, SOL_SOCKET, SO_PEERCRED, cr,
-                      (socklen_t *) &cl) < 0) {
-               _E("peer information error");
-               close(*clifd);
-               return NULL;
-       }
-
-       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
-       if(pkt == NULL) {
-               close(*clifd);
-               return NULL;
-       }
-       memset(pkt, 0, AUL_SOCK_MAXBUFF);
-
-       __set_sock_option(*clifd, 1);
-
- retry_recv:
-       /* receive single packet from socket */
-       len = recv(*clifd, pkt, AUL_SOCK_MAXBUFF, 0);
-       if (len < 0)
-               if (errno == EINTR)
-                       goto retry_recv;
-
-       if ((len < 8) || (len != (pkt->len + 8))) {
-               _E("recv error %d %d", len, pkt->len);
-               free(pkt);
-               close(*clifd);
-               return NULL;
-       }
-
-       return pkt;
+    int len;
+    struct sockaddr_un aul_addr;
+    memset(&aul_addr, 0, sizeof(aul_addr));
+    int sun_size;
+    app_pkt_t *pkt = NULL;
+    int cl = sizeof(struct ucred);
+
+    sun_size = sizeof(struct sockaddr_un);
+
+    if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,
+                         (socklen_t *) &sun_size)) == -1)
+    {
+        if (errno != EINTR) {
+            _E("accept error");
+        }
+        return NULL;
+    }
+
+    if (getsockopt(*clifd, SOL_SOCKET, SO_PEERCRED, cr,
+                  (socklen_t *) &cl) < 0)
+    {
+        _E("peer information error");
+        close(*clifd);
+        return NULL;
+    }
+
+    pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+    if(pkt == NULL) {
+        close(*clifd);
+        return NULL;
+    }
+    memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+    if (0 != __set_sock_option(*clifd, 1)) {
+            free(pkt);
+            close(*clifd);
+            return NULL;
+    }
+
+retry_recv:
+    /* receive single packet from socket */
+    len = recv(*clifd, pkt, AUL_SOCK_MAXBUFF, 0);
+    if (len < 0) {
+        if (errno == EINTR) {
+            goto retry_recv;
+        }
+    }
+
+    if ((len < 8) || (len != (pkt->len + 8))) {
+        _E("recv error %d %d", len, pkt->len);
+        free(pkt);
+        close(*clifd);
+        return NULL;
+    }
+
+    return pkt;
 }
 
 app_pkt_t *__app_send_cmd_with_result(int pid, int cmd)
 {
-       int fd;
-       int len;
-       app_pkt_t *pkt = NULL;
-
-       fd = __create_client_sock(pid);
-       if (fd < 0)
-               return NULL;
-
-       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
-       if (NULL == pkt) {
-               _E("Malloc Failed!");
-               return NULL;
-       }
-       memset(pkt, 0, AUL_SOCK_MAXBUFF);
-
-       pkt->cmd = cmd;
-       pkt->len = 0;
-
-       if ((len = send(fd, pkt, 8, 0)) != 8) {
-               _E("sendto() failed - %d", len);
-               if (errno == EPIPE) {
-                       _E("pid:%d, fd:%d\n", pid, fd);
-               }
-               close(fd);
-
-               free(pkt);
-               return NULL;
-       }
+    int fd;
+    int len;
+    app_pkt_t *pkt = NULL;
+
+    fd = __create_client_sock(pid);
+    if (fd < 0) {
+        return NULL;
+    }
+
+    pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+    if (NULL == pkt) {
+        _E("Malloc Failed!");
+        return NULL;
+    }
+    memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+    pkt->cmd = cmd;
+    pkt->len = 0;
+
+    if ((len = send(fd, pkt, 8, 0)) != 8) {
+        _E("sendto() failed - %d", len);
+        if (errno == EPIPE) {
+            _E("pid:%d, fd:%d\n", pid, fd);
+        }
+        close(fd);
+
+        free(pkt);
+        return NULL;
+    }
 
 retry_recv:
-       /* receive single packet from socket */
-       len = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
-       if (len == -1) {
-               if (errno == EAGAIN) {
-                       _E("recv timeout \n");
-                       free(pkt);
-                       return NULL;
-               } else if (errno == EINTR) {
-                       goto retry_recv;
-               } else {
-                       _E("recv error %s\n", strerror(errno));
-                       free(pkt);
-                       return NULL;
-               }
-       } else
-               _D("recv result  = %d", len);
-       close(fd);
-
-       return pkt;
+    /* receive single packet from socket */
+    len = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
+    if (len == -1) {
+        if (errno == EAGAIN) {
+            _E("recv timeout \n");
+            free(pkt);
+            return NULL;
+        } else if (errno == EINTR) {
+            goto retry_recv;
+        } else {
+            _E("recv error %s\n", strerror(errno));
+            free(pkt);
+            return NULL;
+        }
+    } else {
+        _D("recv result  = %d", len);
+    }
+    close(fd);
+
+    return pkt;
 }
 
-
index c4cf4d8..6f87ad4 100644 (file)
@@ -14,7 +14,6 @@
  *    limitations under the License.
  */
 
-
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>
 #include "simple_util.h"
 
-#define BINSH_NAME     "/bin/sh"
-#define BINSH_SIZE     7
-
-#define PROC_STAT_GID_POS      5
+#define BINSH_NAME      "/bin/sh"
+#define BINSH_SIZE      7
 
+#define PROC_STAT_GID_POS       5
 
 static inline int __read_proc(const char *path, char *buf, int size);
 static inline int __find_pid_by_cmdline(const char *dname,
-                                     const char *cmdline, void *priv);
+                                        const char *cmdline, void *priv);
 static inline int __get_pgid_from_stat(int pid);
 
-
 static inline int __read_proc(const char *path, char *buf, int size)
 {
-       int fd;
-       int ret;
+    int fd;
+    int ret;
 
-       if (buf == NULL || path == NULL)
-               return -1;
+    if (buf == NULL || path == NULL) {
+        return -1;
+    }
 
-       fd = open(path, O_RDONLY);
-       if (fd < 0)
-               return -1;
+    fd = open(path, O_RDONLY);
+    if (fd < 0) {
+        return -1;
+    }
 
-       ret = read(fd, buf, size - 1);
-       if (ret <= 0) {
-               close(fd);
-               return -1;
-       } else
-               buf[ret] = 0;
+    ret = read(fd, buf, size - 1);
+    if (ret <= 0) {
+        close(fd);
+        return -1;
+    } else {
+        buf[ret] = 0;
+    }
 
-       close(fd);
+    close(fd);
 
-       return ret;
+    return ret;
 }
 
 static inline int __find_pid_by_cmdline(const char *dname,
-                                     const char *cmdline, void *priv)
+                                        const char *cmdline, void *priv)
 {
-       char *apppath;
-       int pid = 0;
-
-       apppath = (char *)priv;
-       if (strncmp(cmdline, apppath, MAX_LOCAL_BUFSZ-1) == 0) {
-               pid = atoi(dname);
-               if (pid != getpgid(pid))
-                       pid = 0;
-       }
-
-       return pid;
+    char *apppath;
+    int pid = 0;
+
+    apppath = (char *)priv;
+    if (strncmp(cmdline, apppath, MAX_LOCAL_BUFSZ - 1) == 0) {
+        pid = atoi(dname);
+        if (pid != getpgid(pid)) {
+            pid = 0;
+        }
+    }
+
+    return pid;
 }
 
 int __proc_iter_cmdline(
-       int (*iterfunc)(const char *dname, const char *cmdline, void *priv),
-                   void *priv)
+    int (*iterfunc)(const char *dname, const char *cmdline, void *priv),
+    void *priv)
 {
-       DIR *dp;
-       struct dirent *dentry;
-       int pid;
-       int ret;
-       char buf[MAX_LOCAL_BUFSZ];
-
-       dp = opendir("/proc");
-       if (dp == NULL) {
-               return -1;
-       }
-
-       if (iterfunc == NULL)
-               iterfunc = __find_pid_by_cmdline;
-
-       while ((dentry = readdir(dp)) != NULL) {
-               if (!isdigit(dentry->d_name[0]))
-                       continue;
-
-               snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
-               ret = __read_proc(buf, buf, sizeof(buf));
-               if (ret <= 0)
-                       continue;
-
-               /* support app launched by shell script*/
-               if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
-                       pid =
-                           iterfunc(dentry->d_name, &buf[BINSH_SIZE + 1],
-                                    priv);
-               else
-                       pid = iterfunc(dentry->d_name, buf, priv);
-
-               if (pid > 0) {
-                       closedir(dp);
-                       return pid;
-               }
-       }
-
-       closedir(dp);
-       return -1;
+    DIR *dp;
+    struct dirent dentry;
+    struct dirent *result;
+    int pid;
+    int ret;
+    char buf[MAX_LOCAL_BUFSZ];
+
+    dp = opendir("/proc");
+    if (dp == NULL) {
+        return -1;
+    }
+
+    if (iterfunc == NULL) {
+        iterfunc = __find_pid_by_cmdline;
+    }
+
+    while (readdir_r(dp, &dentry, &result) == 0 && result != NULL) {
+        if (!isdigit(dentry.d_name[0])) {
+            continue;
+        }
+
+        snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry.d_name);
+        ret = __read_proc(buf, buf, sizeof(buf));
+        if (ret <= 0) {
+            continue;
+        }
+
+        /* support app launched by shell script*/
+        if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0) {
+            pid =
+                iterfunc(dentry.d_name, &buf[BINSH_SIZE + 1],
+                         priv);
+        } else {
+            pid = iterfunc(dentry.d_name, buf, priv);
+        }
+
+        if (pid > 0) {
+            closedir(dp);
+            return pid;
+        }
+    }
+
+    closedir(dp);
+    return -1;
 }
 
 char *__proc_get_cmdline_bypid(int pid)
 {
-       char buf[MAX_LOCAL_BUFSZ];
-       int ret;
-
-       snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
-       ret = __read_proc(buf, buf, sizeof(buf));
-       if (ret <= 0)
-               return NULL;
-
-       /* support app launched by shell script*/
-       if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
-               return strdup(&buf[BINSH_SIZE + 1]);
-       else
-               return strdup(buf);
+    char buf[MAX_LOCAL_BUFSZ];
+    int ret;
+
+    snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
+    ret = __read_proc(buf, buf, sizeof(buf));
+    if (ret <= 0) {
+        return NULL;
+    }
+
+    /* support app launched by shell script*/
+    if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0) {
+        return strdup(&buf[BINSH_SIZE + 1]);
+    } else {
+        return strdup(buf);
+    }
 }
 
 static inline int __get_pgid_from_stat(int pid)
 {
-       char buf[MAX_LOCAL_BUFSZ];
-       char *str;
-       int ret;
-       int i;
-       int count = 0;
-
-       if (pid <= 1)
-               return -1;
-
-       snprintf(buf, sizeof(buf), "/proc/%d/stat", pid);
-       ret = __read_proc(buf, buf, sizeof(buf));
-       if (ret < 0)
-               return -1;
-
-       for (i = 0; i < (ret - 1); i++) {
-               if (buf[i] == ' ') {
-                       count++;
-                       if (count == PROC_STAT_GID_POS - 1)
-                               str = &(buf[i + 1]);
-                       else if (count == PROC_STAT_GID_POS) {
-                               buf[i] = 0;
-                               break;
-                       }
-               }
-       }
-
-       if (count == PROC_STAT_GID_POS)
-               pid = atoi(str);
-       else
-               pid = -1;
-
-       return pid;
+    char buf[MAX_LOCAL_BUFSZ];
+    char *str;
+    int ret;
+    int i;
+    int count = 0;
+
+    if (pid <= 1) {
+        return -1;
+    }
+
+    snprintf(buf, sizeof(buf), "/proc/%d/stat", pid);
+    ret = __read_proc(buf, buf, sizeof(buf));
+    if (ret < 0) {
+        return -1;
+    }
+
+    for (i = 0; i < (ret - 1); i++) {
+        if (buf[i] == ' ') {
+            count++;
+            if (count == PROC_STAT_GID_POS - 1) {
+                str = &(buf[i + 1]);
+            } else if (count == PROC_STAT_GID_POS) {
+                buf[i] = 0;
+                break;
+            }
+        }
+    }
+
+    if (count == PROC_STAT_GID_POS) {
+        pid = atoi(str);
+    } else {
+        pid = -1;
+    }
+
+    return pid;
 }
 
-int __proc_iter_pgid(int pgid, int (*iterfunc) (int pid, void *priv),
-                    void *priv)
+int __proc_iter_pgid(int pgid, int (*iterfunc)(int pid, void *priv),
+                     void *priv)
 {
-       DIR *dp;
-       struct dirent *dentry;
-       int _pgid;
-       int ret = -1;
-
-       dp = opendir("/proc");
-       if (dp == NULL) {
-               return -1;
-       }
-
-       while ((dentry = readdir(dp)) != NULL) {
-               if (!isdigit(dentry->d_name[0]))
-                       continue;
-
-               _pgid = __get_pgid_from_stat(atoi(dentry->d_name));
-               if (pgid == _pgid) {
-                       ret = iterfunc(atoi(dentry->d_name), priv);
-                       if (ret >= 0)
-                               break;
-               }
-       }
-
-       closedir(dp);
-       return ret;
+    DIR *dp;
+    struct dirent dentry;
+    struct dirent *result;
+    int _pgid;
+    int ret = -1;
+
+    dp = opendir("/proc");
+    if (dp == NULL) {
+        return -1;
+    }
+
+    while (readdir_r(dp, &dentry, &result) == 0 && result != NULL) {
+        if (!isdigit(dentry.d_name[0])) {
+            continue;
+        }
+
+        _pgid = __get_pgid_from_stat(atoi(dentry.d_name));
+        if (pgid == _pgid) {
+            ret = iterfunc(atoi(dentry.d_name), priv);
+            if (ret >= 0) {
+                break;
+            }
+        }
+    }
+
+    closedir(dp);
+    return ret;
 }
 
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..da45ba9
--- /dev/null
@@ -0,0 +1,19 @@
+# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+# @author      Karol Pawlowski (k.pawlowski@samsung.com)
+#
+
+ADD_SUBDIRECTORY(widgets)
diff --git a/tests/widgets/CMakeLists.txt b/tests/widgets/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3037631
--- /dev/null
@@ -0,0 +1,83 @@
+# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+# @author      Karol Pawlowski (k.pawlowski@samsung.com)
+#
+
+# TODO cleanup dependencies
+PKG_CHECK_MODULES(COMMON_LIB_PKGS
+    dbus-1
+    libpcrecpp
+    dpl-efl
+    dpl-test-efl
+    dpl-utils-efl
+    dpl-wrt-dao-ro
+    dpl-event-efl
+    wrt-plugins-widgetdb
+    glib-2.0
+    gthread-2.0
+    ewebkit2
+    edje
+    ecore
+    ecore-x
+    ecore-imf
+    ecore-ipc
+    ecore-evas
+    ecore-file
+    ecore-input
+    evas
+    eina
+    elementary
+    vconf
+    aul
+    libidn
+    libiri
+    REQUIRED
+    )
+
+INCLUDE(CMakeUtils.txt)
+
+pkg_search_module(dpl REQUIRED dpl-efl)
+pkg_search_module(dpl-test REQUIRED dpl-test-efl)
+
+SET(WRT_TEST_LIBRARY "wrt-tests-libs")
+
+include_directories(
+  ${dpl_INCLUDE_DIRS}
+  ${dpl-test_INCLUDE_DIRS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/common
+  ${PROJECT_SOURCE_DIR}/src/view
+  ${WRT_API_NEW_INCLUDES}
+)
+
+ADD_SUBDIRECTORY(files)
+ADD_SUBDIRECTORY(common)
+
+SET(TESTS_SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/TestInit.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/TestCases.cpp
+)
+
+SET(TESTS_TARGET "wrt-tests-general")
+
+WRT_TEST_BUILD(${TESTS_TARGET} ${TESTS_SOURCES})
+WRT_TEST_INSTALL(${TESTS_TARGET})
+target_link_libraries(${TESTS_TARGET}
+  ${dpl_LIBRARIES}
+  ${dpl-test_LIBRARIES}
+  ${WRT_TEST_LIBRARY}
+  ${TARGET_CORE_MODULE_LIB}
+  ${COMMON_LIB_PKGS_LIBRARIES}
+)
diff --git a/tests/widgets/CMakeUtils.txt b/tests/widgets/CMakeUtils.txt
new file mode 100644 (file)
index 0000000..265869f
--- /dev/null
@@ -0,0 +1,182 @@
+# @file        CMakeUtils.txt
+# @author      Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+# @author      Pawel Sikorski (p.sikorski@samsung.com)
+# @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version     1.0
+# @brief
+#
+
+#
+# Discovers target's INCLUDE_DIRECTORIES and LINK_DIRECTORIES.
+# This is done by retrieving the directory target was built in and
+# fetching appropriate properties of that directory.
+FUNCTION(WRT_INTROSPECT_TARGET PREFIX TARGET_NAME)
+  GET_TARGET_PROPERTY(LOCATION ${TARGET_NAME} LOCATION)
+  IF(${LOCATION} STREQUAL "LOCATION-NOTFOUND")
+    MESSAGE(FATAL_ERROR "Target '${TARGET_NAME}' introspection failed")
+  ELSE(${LOCATION} STREQUAL "LOCATION-NOTFOUND")
+    STRING(FIND ${LOCATION} "/" LAST_SLASH_POSITION REVERSE)
+    STRING(SUBSTRING ${LOCATION} 0 ${LAST_SLASH_POSITION} LOCATION)
+
+    GET_DIRECTORY_PROPERTY(INCLUDE_DIRS DIRECTORY ${LOCATION} INCLUDE_DIRECTORIES)
+    SET("${PREFIX}_INCLUDE_DIRS" ${INCLUDE_DIRS} PARENT_SCOPE)
+
+    GET_DIRECTORY_PROPERTY(LIBRARY_DIRS DIRECTORY ${LOCATION} LINK_DIRECTORIES)
+    SET("${PREFIX}_LIBRARY_DIRS" ${LIBRARY_DIRS} PARENT_SCOPE)
+  ENDIF(${LOCATION} STREQUAL "LOCATION-NOTFOUND")
+ENDFUNCTION(WRT_INTROSPECT_TARGET)
+
+FUNCTION(WRT_TEST_LIBRARY)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY COMMON_TESTS_LIBRARY ${ARGV})
+ENDFUNCTION(WRT_TEST_LIBRARY)
+
+#
+# Replacement functions for standard (w/o "WRT_" prefix) CMake functions.
+# They store supplied arguments in global properties to assign them to tests.
+# Anything added with this functions is used by all targets that are built with
+# WRT_TEST_BUILD function.
+
+#
+# Appends directories to global property TESTS_INCLUDE_DIRS which is
+# then read by WRT_TEST_BUILD and its content is forwarded to
+# command INCLUDE_DIRECTORIES() (for all targets).
+FUNCTION(WRT_INCLUDE_DIRECTORIES)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_INCLUDE_DIRS ${ARGV})
+ENDFUNCTION(WRT_INCLUDE_DIRECTORIES)
+
+#
+# Appends directories to global property TESTS_LIBRARY_DIRS which is
+# then read by WRT_TEST_BUILD and its content is forwarded to
+# command LINK_DIRECTORIES() (for all targets).
+FUNCTION(WRT_LINK_DIRECTORIES)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARY_DIRS ${ARGV})
+ENDFUNCTION(WRT_LINK_DIRECTORIES)
+
+#
+# Appends directories to global property TESTS_LIBRARIES which is
+# then read by WRT_TEST_BUILD and its content is forwarded to
+# command TARGET_LINK_LIBRARIES() (for all targets).
+FUNCTION(WRT_TARGET_LINK_LIBRARIES)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARIES ${ARGV})
+ENDFUNCTION(WRT_TARGET_LINK_LIBRARIES)
+
+#
+# Convenience method that fills TESTS_INCLUDE_DIRS, TESTS_LIBRARY_DIRS
+# and TESTS_LIBRARIES with values discovered from introspecting supplied
+# targets.
+# Function takes arbitrary number of targets.
+FUNCTION(WRT_ADD_INTERNAL_DEPENDENCIES)
+  FOREACH(DEPENDENCY ${ARGV})
+    WRT_INTROSPECT_TARGET(prefix ${DEPENDENCY})
+    WRT_INCLUDE_DIRECTORIES(${prefix_INCLUDE_DIRS})
+    WRT_LINK_DIRECTORIES(${prefix_LIBRARY_DIRS})
+    WRT_TARGET_LINK_LIBRARIES(${DEPENDENCY})
+  ENDFOREACH(DEPENDENCY)
+ENDFUNCTION(WRT_ADD_INTERNAL_DEPENDENCIES)
+
+
+#
+# Replacement functions for standard (w/o "WRT_" prefix) CMake functions.
+# They store supplied arguments in global properties to assign them to specific
+# tests. Properties names are based on the test target name.
+# Anything added with this functions is used only by the specified target that
+# is built with WRT_TEST_BUILD function.
+
+#
+# Appends directories to global property ${TARGET_NAME}_INCLUDE_DIRS
+# which is then read by WRT_TEST_BUILD and its content is forwarded to
+# command INCLUDE_DIRECTORIES() (for specified target).
+FUNCTION(WRT_TEST_INCLUDE_DIRECTORIES TARGET_NAME)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY ${TARGET_NAME}_INCLUDE_DIRS ${ARGN})
+ENDFUNCTION(WRT_TEST_INCLUDE_DIRECTORIES)
+
+#
+# Appends directories to global property ${TARGET_NAME}_LIBRARY_DIRS
+# which is then read by WRT_TEST_BUILD and its content is forwarded to
+# command LINK_DIRECTORIES() (for specified target).
+FUNCTION(WRT_TEST_LINK_DIRECTORIES TARGET_NAME)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY ${TARGET_NAME}_LIBRARY_DIRS ${ARGN})
+ENDFUNCTION(WRT_TEST_LINK_DIRECTORIES)
+
+#
+# Appends directories to global property ${TARGET_NAME}_LIBRARIES
+# which is then read by WRT_TEST_BUILD and its content is forwarded to
+# command TARGET_LINK_LIBRARIES() (for specified target).
+FUNCTION(WRT_TEST_TARGET_LINK_LIBRARIES TARGET_NAME)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY ${TARGET_NAME}_LIBRARIES ${ARGN})
+ENDFUNCTION(WRT_TEST_TARGET_LINK_LIBRARIES)
+
+#
+# Convenience method that fills ${TARGET_NAME}_INCLUDE_DIRS,
+# ${TARGET_NAME}_LIBRARY_DIRS and ${TARGET_NAME}_LIBRARIES with
+# values discovered from introspecting supplied targets.
+# Function takes arbitrary number of targets.
+FUNCTION(WRT_TEST_ADD_INTERNAL_DEPENDENCIES TARGET_NAME)
+  FOREACH(DEPENDENCY ${ARGN})
+    WRT_INTROSPECT_TARGET(prefix ${DEPENDENCY})
+    WRT_TEST_INCLUDE_DIRECTORIES(${TARGET_NAME} ${prefix_INCLUDE_DIRS})
+    WRT_TEST_LINK_DIRECTORIES(${TARGET_NAME} ${prefix_LIBRARY_DIRS})
+    WRT_TEST_TARGET_LINK_LIBRARIES(${TARGET_NAME} ${DEPENDENCY})
+  ENDFOREACH(DEPENDENCY)
+ENDFUNCTION(WRT_TEST_ADD_INTERNAL_DEPENDENCIES)
+
+# Functions used to build test targets (proper sources, includes, libs are
+# added automatically)
+FUNCTION(WRT_TEST_BUILD TARGET_NAME)
+    SET(SOURCES "${ARGN}")
+    ADD_EXECUTABLE("${TARGET_NAME}" ${SOURCES})
+
+    # get include dirs global property
+    GET_PROPERTY(INCLUDE_DIRS GLOBAL PROPERTY TESTS_INCLUDE_DIRS)
+    GET_PROPERTY(TEST_INCLUDE_DIRS GLOBAL PROPERTY ${TARGET_NAME}_INCLUDE_DIRS)
+    INCLUDE_DIRECTORIES(
+        ${INCLUDE_DIRS}
+        ${TEST_INCLUDE_DIRS}
+    )
+
+    # get library dirs global property
+    GET_PROPERTY(LIBRARY_DIRS GLOBAL PROPERTY TESTS_LIBRARY_DIRS)
+    GET_PROPERTY(TEST_LIBRARY_DIRS GLOBAL PROPERTY ${TARGET_NAME}_LIBRARY_DIRS)
+    LINK_DIRECTORIES(
+        ${LIBRARY_DIRS}
+        ${TEST_LIBRARY_DIRS}
+    )
+
+    # get link libraries global property
+    GET_PROPERTY(LINK_LIBRARIES GLOBAL PROPERTY TESTS_LIBRARIES)
+    GET_PROPERTY(TEST_LIBRARIES GLOBAL PROPERTY ${TARGET_NAME}_LIBRARIES)
+    TARGET_LINK_LIBRARIES("${TARGET_NAME}"
+        ${LINK_LIBRARIES}
+        ${TEST_LIBRARIES}
+    )
+ENDFUNCTION(WRT_TEST_BUILD)
+
+FUNCTION(WRT_TEST_INSTALL)
+    SET_TARGET_PROPERTIES(${ARGV} PROPERTIES
+        BUILD_WITH_INSTALL_RPATH ON
+        INSTALL_RPATH_USE_LINK_PATH ON
+    )
+    INSTALL(TARGETS ${ARGV}
+        DESTINATION bin
+        PERMISSIONS OWNER_READ
+                    OWNER_WRITE
+                    OWNER_EXECUTE
+                    GROUP_READ
+                    GROUP_EXECUTE
+                    WORLD_READ
+                    WORLD_EXECUTE
+    )
+ENDFUNCTION(WRT_TEST_INSTALL)
+
+# Takes arbitrary number of arguments and concatenates them using ':' character.
+# Rationale:
+#   CMake list when converted to a string is joined with ';' character. However,
+#   GCC takes strings with multiple elements separated with ':' (e.g. list of
+#   paths). Used typically when generating DB schemas with ORM mechanism.
+FUNCTION(WRT_CONVERT_TO_GCC_LIST OUTPUT_VARIABLE)
+    FOREACH(ITEM ${ARGN})
+        LIST(APPEND ITEMS ${ITEM})
+    ENDFOREACH(ITEM)
+    STRING(REPLACE ";" ":" OUTPUT "${ITEMS}")
+    SET("${OUTPUT_VARIABLE}" "${OUTPUT}" PARENT_SCOPE)
+ENDFUNCTION(WRT_CONVERT_TO_GCC_LIST)
diff --git a/tests/widgets/TestCases.cpp b/tests/widgets/TestCases.cpp
new file mode 100644 (file)
index 0000000..1af0bfe
--- /dev/null
@@ -0,0 +1,1110 @@
+/*
+ * 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    TestCases.cpp
+ * @author  Karol PawÅ‚owski (k.pawlowski@samsung.com)
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/singleton_impl.h>
+#include <dpl/log/log.h>
+#include <RunnableObjectStateTester.h>
+#include <i_runnable_widget_object.h>
+
+namespace {
+
+struct Result {
+    bool m_exc;
+    bool m_exd;
+    bool m_exs;
+    std::string message;
+    Result(bool exc = false, bool exd = false, bool exs = false)
+        : m_exc(exc), m_exd(exd), m_exs(exs) {}
+};
+
+}
+
+RUNNER_TEST_GROUP_INIT(RunnableWidgetObjectState)
+
+//for call methods to get starting state or do clean up after test
+#define CALL_TESTER( ARGUMENT )                                        \
+        tester.perform##ARGUMENT();                                    \
+
+//for performing test and catch excpeted and unexpected exceptions
+#define RUNNABLE_TESTER( ARGUMENT )                                    \
+    Result res;                                                        \
+    Try                                                                \
+    {                                                                  \
+        LogDebug("perform start");                                     \
+        CALL_TESTER( ARGUMENT )                                        \
+        LogDebug("perform stop");                                      \
+    }                                                                  \
+    Catch(WRT::IRunnableWidgetObject::MethodInvocationForbidden)       \
+    {                                                                  \
+        res.m_exc = true;                                              \
+        res.message = _rethrown_exception.DumpToString();              \
+        res.message += "(MethodInvocationForbidden)";                  \
+    }                                                                  \
+    Catch(DPL::Exception)                                              \
+    {                                                                  \
+        res.m_exd = true;                                              \
+        res.message = _rethrown_exception.DumpToString();              \
+        res.message += "(DPL::Exception)";                             \
+    }                                                                  \
+    Catch(std::exception)                                              \
+    {                                                                  \
+        res.m_exs = true;                                              \
+        res.message = _rethrown_exception.what();                      \
+        res.message += "(std::exception)";                             \
+    }                                                                  \
+
+
+//check of function success
+#define SHOULD_BE_ALLOWED( ARGUMENT )                                  \
+    {                                                                  \
+    RUNNABLE_TESTER( ARGUMENT )                                        \
+    if(res.m_exc || res.m_exs || res.m_exd)                            \
+    {                                                                  \
+        ok = false;                                                    \
+        reason = "Exception throwed when not expected in ";            \
+        reason += __FUNCTION__;                                        \
+        reason += " calling ";                                         \
+        reason += #ARGUMENT;                                           \
+        reason += "message ";                                          \
+        reason += res.message;                                         \
+    }                                                                  \
+    }                                                                  \
+
+
+//check of function failure
+#define SHOULD_BE_FORBIDDEN( ARGUMENT )                                \
+    {                                                                  \
+    RUNNABLE_TESTER( ARGUMENT )                                        \
+    if(!res.m_exc)                                                     \
+    {                                                                  \
+        ok = false;                                                    \
+        reason = "MethodInvocationForbidden should be throwed";        \
+        reason += " when calling ";                                    \
+        reason += #ARGUMENT;                                           \
+    }                                                                  \
+    }                                                                  \
+
+
+//marcos for hiding lamdba expression and and presenting it as if it is test body
+#define RUNNABLE_TESTER_START                                                              \
+    bool ok = true;                                                                        \
+    std::string reason;                                                                    \
+    auto func = [&ok,&reason](RunnableObjectStateTester & tester)                          \
+    {                                                                                      \
+        Try                                                                                \
+        {                                                                                  \
+
+
+#define RUNNABLE_TESTER_STOP                                                               \
+        }                                                                                  \
+        Catch(DPL::Exception)                                                              \
+        {                                                                                  \
+            ok = false;                                                                    \
+            reason = _rethrown_exception.DumpToString();                                   \
+            reason += "(DPL::Exception)";                                                  \
+        }                                                                                  \
+        Catch(std::exception)                                                              \
+        {                                                                                  \
+            reason = "Unknown exception";                                                  \
+            ok = false;                                                                    \
+        }                                                                                  \
+    };                                                                                     \
+    RunnableObjectStateTester & instance = RunnableObjectStateTesterSingleton::Instance(); \
+    instance.runTest(func);                                                                \
+    RUNNER_ASSERT_MSG(ok, reason);                                                         \
+
+//Initial
+/*
+Name: state_Initial_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_CheckBeforeLaunch)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Initial
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Initial_PrepareView)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_ALLOWED( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Show)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Show );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Hide)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Suspend)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Suspend );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Resume)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Resume );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Reset)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Reset );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_GetCurrentWebview)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( GetCurrentWebview );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_SetUserDelegates)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Backward)
+{
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Backward );
+    RUNNABLE_TESTER_STOP
+}
+
+
+//Prepared
+/*
+Name: state_Prepared_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Prepared
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Prepared_CheckBeforeLaunch)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_ALLOWED( CheckBeforeLaunch );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_PrepareView)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Show)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Show );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Prepared
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Prepared_Hide)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_ALLOWED( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Suspend)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Suspend );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Resume)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Resume );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Reset)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Reset );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Prepared
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Prepared_GetCurrentWebview)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_SetUserDelegates)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Backward)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Backward );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+//SecChecked
+/*
+Name: state_SecChecked_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_CheckBeforeLaunch)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_PrepareView)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state SecChecked
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_SecChecked_Show)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( SetUserDelegates );
+    SHOULD_BE_ALLOWED( Show );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state SecChecked
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_SecChecked_Hide)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_ALLOWED( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_Suspend)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( Suspend );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_Resume)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( Resume );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_Reset)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( Reset );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state SecChecked
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_SecChecked_GetCurrentWebview)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state SecChecked
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_SecChecked_SetUserDelegates)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_ALLOWED( SetUserDelegates );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_Backward)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( Backward );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+//Showed
+/*
+Name: state_Showed_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_CheckBeforeLaunch)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_PrepareView)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_Show)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( Show );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_Hide)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_Suspend)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( Suspend );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_Resume)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( Resume );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_Reset)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( Reset );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_GetCurrentWebview)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_SetUserDelegates)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_Backward)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( Backward );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+//Suspended
+/*
+Name: state_Suspended_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_CheckBeforeLaunch)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_PrepareView)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_Show)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( Show );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Suspended
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Suspended_Hide)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_ALLOWED( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_Suspend)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( Suspend );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Suspended
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Suspended_Resume)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_ALLOWED( Resume );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Suspended
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Suspended_Reset)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_ALLOWED( Reset );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Suspended
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Suspended_GetCurrentWebview)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_SetUserDelegates)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_Backward)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( Backward );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+//Hidden
+/*
+Name: state_Hidden_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_CheckBeforeLaunch)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_PrepareView)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Show)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Show );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Hide)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Suspend)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Suspend );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Resume)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Resume );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Reset)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Reset );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Hidden
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Hidden_GetCurrentWebview)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_SetUserDelegates)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Backward)
+{
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Backward );
+    RUNNABLE_TESTER_STOP
+}
+
diff --git a/tests/widgets/TestInit.cpp b/tests/widgets/TestInit.cpp
new file mode 100644 (file)
index 0000000..2e1ac8f
--- /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    TestInit.cpp
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief   main for misc tests
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+
+int main (int argc, char *argv[])
+{
+    LogInfo("Starting tests");
+
+    WrtDB::WrtDatabase::attachToThreadRW();
+    int status =
+        DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+    WrtDB::WrtDatabase::detachFromThread();
+
+    return status;
+}
diff --git a/tests/widgets/common/CMakeLists.txt b/tests/widgets/common/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e47d3d9
--- /dev/null
@@ -0,0 +1,43 @@
+# 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      Tomasz Iwanek (t.iwanek@samsung.com)
+# @version     1.0
+# @brief
+#
+
+SET(COMMON_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include")
+
+WRT_TEST_LIBRARY(${WRT_TEST_LIBRARY})
+
+WRT_INCLUDE_DIRECTORIES(
+    ${COMMON_LIB_PKGS_INCLUDE_DIRS}
+    ${COMMON_INCLUDES}
+    ${WRT_API_NEW_INCLUDES}
+    )
+
+WRT_LINK_DIRECTORIES(${COMMON_LIB_PKGS_LIBRARY_DIRS})
+WRT_TARGET_LINK_LIBRARIES(${COMMON_LIB_PKGS_LIBRARIES})
+
+SET(WRT_DETAIL_SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/InstallerWrapper.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/RunnableObjectStateTester.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/mock/MockViewModule.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/mock/MockContextManager.cpp
+)
+
+INCLUDE_DIRECTORIES(${COMMON_INCLUDES})
+INCLUDE_DIRECTORIES(${COMMON_LIB_PKGS_INCLUDE_DIRS})
+ADD_LIBRARY(${WRT_TEST_LIBRARY} STATIC ${WRT_DETAIL_SOURCES})
diff --git a/tests/widgets/common/include/InstallerWrapper.h b/tests/widgets/common/include/InstallerWrapper.h
new file mode 100644 (file)
index 0000000..7bce1cd
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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 WRT_TESTS_W3C_TESTS_INSTALLER_WRAPPER_H
+#define WRT_TESTS_W3C_TESTS_INSTALLER_WRAPPER_H
+
+#include <string>
+
+namespace InstallerWrapper
+{
+
+typedef int InstallResult;
+const InstallResult WrongWidgetPackage = -2;
+const InstallResult OtherError = -1;
+const InstallResult Success = 0;
+
+InstallResult install(
+        const std::string& path,
+        std::string& tizenId,
+        const std::string& user = "");
+bool uninstall(const std::string& tizenId);
+bool uninstallByGuid(const std::string& guid);
+/**
+ * @brief killWrtClients kills processes that matches 'wrt-client'
+ * @return True if any client was killed
+ */
+bool sigintWrtClients();
+
+}
+
+#endif//WRT_TESTS_W3C_TESTS_INSTALLER_WRAPPER_H
diff --git a/tests/widgets/common/include/RunnableObjectStateTester.h b/tests/widgets/common/include/RunnableObjectStateTester.h
new file mode 100644 (file)
index 0000000..e9f107c
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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        RunnableObjectStateTester.h
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Tester for RunnableWidgetObject's states
+ */
+
+#ifndef WRT_EXTRA_AUTO_TESTS_COMMON_INCLUDE_RUNNABLE_OBJECT_STATE_TESTER_H
+#define WRT_EXTRA_AUTO_TESTS_COMMON_INCLUDE_RUNNABLE_OBJECT_STATE_TESTER_H
+
+#include <memory>
+#include <functional>
+#include <vector>
+#include <Evas.h>
+#include <dpl/exception.h>
+#include <dpl/application.h>
+#include <dpl/generic_event.h>
+#include <dpl/event/controller.h>
+#include <dpl/type_list.h>
+#include <dpl/task.h>
+#include <dpl/singleton.h>
+#include <dpl/string.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <runnable_widget_object.h>
+#include <core_module.h>
+
+#include <InstallerWrapper.h>
+
+DECLARE_GENERIC_EVENT_0(NextStepEvent)
+
+class RunnableObjectStateTester : public DPL::ApplicationExt,
+        private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
+        public DPL::TaskDecl<RunnableObjectStateTester>
+{
+public:
+    typedef std::function<void(RunnableObjectStateTester&)> Test;
+
+    DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+    DECLARE_EXCEPTION_TYPE(Base, CoreModuleFailure)
+    DECLARE_EXCEPTION_TYPE(Base, CallbackFailure)
+
+    RunnableObjectStateTester();
+    ~RunnableObjectStateTester();
+
+    void performCheckBeforeLaunch();
+    void performPrepareView();
+
+    void performShow();
+    void performHide();
+    void performSuspend();
+    void performResume();
+    void performReset();
+
+    void performGetCurrentWebview();
+    void performSetUserDelegates();
+    void performBackward();
+
+    void performTest();
+
+    void runTest(Test func);
+
+    void OnEventReceived(const NextStepEvent& /*event*/);
+
+    void loadFinishCallback(Evas_Object*);
+
+private:
+    std::string m_handle;
+    WRT::RunnableWidgetObjectPtr m_widget;
+    Test m_func;
+    const std::string m_widgetPath;
+};
+
+typedef DPL::Singleton<RunnableObjectStateTester> RunnableObjectStateTesterSingleton;
+
+#endif // WRT_EXTRA_AUTO_TESTS_COMMON_INCLUDE_RUNNABLE_OBJECT_STATE_TESTER_H
diff --git a/tests/widgets/common/include/mock/MockContextManager.h b/tests/widgets/common/include/mock/MockContextManager.h
new file mode 100644 (file)
index 0000000..b3a6b7f
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file        MockContextManager.h
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Mock for view module
+ */
+#ifndef MOCKCONTEXTMANAGER_H
+#define MOCKCONTEXTMANAGER_H
+
+#include <abstract_context_manager.h>
+
+class MockContextManager : public WRT::AbstractContextManager
+{
+public:
+   MockContextManager(const std::string& tizenAppId,
+                       Ewk_Context* ewkContext,
+                       ViewModule::IViewModulePtr viewModule);
+   virtual ~MockContextManager();
+   Ewk_Context* getEwkContext() const;
+   void handleLowMemory();
+};
+
+#endif // MOCKCONTEXTMANAGER_H
diff --git a/tests/widgets/common/include/mock/MockViewModule.h b/tests/widgets/common/include/mock/MockViewModule.h
new file mode 100644 (file)
index 0000000..4149743
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file        MockViewModule.h
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Mock for view module
+ */
+
+#ifndef MOCKVIEWMODULE_H
+#define MOCKVIEWMODULE_H
+
+#include<i_view_module.h>
+
+class MockViewModule : public ViewModule::IViewModule
+{
+public:
+    MockViewModule();
+    bool createWebView(Ewk_Context* context,
+                             Evas_Object* window);
+    void prepareView(WidgetModel *, const std::string &);
+    void showWidget();
+    void hideWidget();
+    void suspendWidget();
+    void resumeWidget();
+    void resetWidget();
+    void backward();
+    void reloadStartPage();
+    Evas_Object* getCurrentWebview();
+    void fireJavascriptEvent(int event, void* data);
+    void setUserCallbacks(const WRT::UserDelegatesPtr& cbs);
+    void checkSyncMessageFromBundle(
+          const char* name,
+          const char* body,
+          char** returnData);
+    void downloadData(const char* url);
+    void activateVibration(bool on, uint64_t time);
+};
+
+#endif // MOCKVIEWMODULE_H
diff --git a/tests/widgets/common/src/InstallerWrapper.cpp b/tests/widgets/common/src/InstallerWrapper.cpp
new file mode 100644 (file)
index 0000000..f2b8e55
--- /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.
+ */
+
+#include "InstallerWrapper.h"
+
+#include <dpl/log/log.h>
+
+#include <cstdio>
+
+namespace
+{
+
+const std::string params = "DPL_USE_OLD_STYLE_LOGS=0 "
+    "DPL_USE_OLD_STYLE_PEDANTIC_LOGS=0 WRT_TEST_MODE=1 ";
+const std::string installCmd = params + "wrt-installer -if ";
+const std::string uninstallCmd = params + "wrt-installer -un ";
+const std::string uninstallByGuidCmd = params + "wrt-installer -ug \"";
+const std::string redirection =  " 2>&1";
+const std::string INSTALLER_MESSAGE_ID_LINE =
+    "## wrt-installer : %s installation was successful.\n";
+const std::string INSTALLER_MESSSGE_START = "## wrt-installer : ";
+
+std::string getAndCutInstallerLogLine(std::string &src)
+{
+    size_t startIndex = src.find(INSTALLER_MESSSGE_START);
+    if (startIndex == std::string::npos)
+    {
+        LogWarning("Installer message can not be found");
+        return std::string();
+    }
+    size_t newLineIndex = src.find("\n", startIndex);
+    std::string line = src.substr(startIndex, newLineIndex - startIndex + 1);
+    src.erase(0, newLineIndex + 1);
+    return line;
+}
+
+}
+
+namespace InstallerWrapper
+{
+
+InstallResult install(
+        const std::string& path,
+        std::string& tizenId,
+        const std::string& user)
+{
+    std::string msg;
+
+    auto cmd = installCmd + path + redirection;
+    if(user.length()) //if other user should be used
+    {
+        cmd = "su " + user + " -c '" + cmd + "'";
+    }
+    LogDebug("executing: " << cmd);
+    auto filehandle = popen(cmd.c_str(), "r");
+    if (!filehandle) {
+        return OtherError;
+    }
+
+    char buffer[1024] = "";
+    while (fread_unlocked(buffer, sizeof(char), sizeof(buffer)/sizeof(char),
+                                 filehandle) > 0)
+    {
+        msg += buffer;
+    }
+    LogDebug(msg);
+    auto err = pclose(filehandle);
+    if (!WIFEXITED(err)) {
+        return OtherError;
+    }
+    if (0 != WEXITSTATUS(err)) {
+        if (1 == WEXITSTATUS(err)) {
+            return WrongWidgetPackage;
+        }
+        return OtherError;
+    }
+
+    char* id = NULL;
+    std::string line;
+
+    while ((line = getAndCutInstallerLogLine(msg)) != "")
+    {
+        if (line.find("successful") != std::string::npos)
+        {
+            id = new char[line.length()];
+            int nr = sscanf(line.c_str(), INSTALLER_MESSAGE_ID_LINE.c_str(), id);
+
+            if (1 != nr)
+            {
+                LogWarning("Can not read widget ID from message: " << line);
+                delete[] id;
+                return OtherError;
+            }
+            tizenId = id;
+            delete[] id;
+            if (tizenId != "plugin")
+            {
+                return Success;
+            }
+        }
+    }
+
+    return OtherError;
+}
+
+bool uninstall(const std::string& tizenId)
+{
+    std::string cmd = uninstallCmd + tizenId + " > /dev/null 2>/dev/null";
+    LogDebug("executing: " << cmd);
+    return (system(cmd.c_str()) == EXIT_SUCCESS);
+}
+
+bool uninstallByGuid(const std::string& guid)
+{
+    std::string cmd = uninstallByGuidCmd + guid + "\" > /dev/null 2>/dev/null";
+    LogDebug("executing: " << cmd);
+    return (system(cmd.c_str()) == EXIT_SUCCESS);
+}
+
+bool sigintWrtClients()
+{
+    return (system("pkill -2 wrt-client") == 0);
+}
+
+}
+
diff --git a/tests/widgets/common/src/RunnableObjectStateTester.cpp b/tests/widgets/common/src/RunnableObjectStateTester.cpp
new file mode 100644 (file)
index 0000000..70ac9e5
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * 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        RunnableObjectStateTester.cpp
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Tester for RunnableWidgetObject's states
+ */
+
+#include "RunnableObjectStateTester.h"
+
+#include <dpl/framework_efl.h>
+#include <dpl/localization/w3c_file_localization.h>
+#include <vector>
+#include <string>
+#include <dpl/noncopyable.h>
+#include <dpl/log/log.h>
+#include <dpl/singleton_impl.h>
+#include <dpl/foreach.h>
+
+#include <mock/MockViewModule.h>
+#include <mock/MockContextManager.h>
+
+IMPLEMENT_SINGLETON(RunnableObjectStateTester)
+
+namespace {
+const std::string widgetPathMnimal = "/opt/share/widget/tests/general/any.wgt";
+const int widgetInitializationTimeBounding = 3;
+}
+
+RunnableObjectStateTester::RunnableObjectStateTester()
+    : DPL::ApplicationExt(1, NULL, "test-app"),
+      DPL::TaskDecl<RunnableObjectStateTester>(this),
+      m_widgetPath(widgetPathMnimal)
+{
+    LogDebug("enter");
+
+    int argc = 0;
+    const char * argv[] = { "wrt-tests-wrt" };
+    if (!getenv("ELM_ENGINE")) {
+        if (setenv("ELM_ENGINE", "gl", 1)) {
+                LogDebug("Enable backend");
+        }
+    }
+    setenv("COREGL_FASTPATH", "1", 1);
+    DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-CLIENT");
+
+    Touch();
+
+    //initialize
+    elm_init(argc, const_cast<char**>(argv));
+    if(!WRT::CoreModuleSingleton::Instance().Init())
+    {
+        ThrowMsg(CoreModuleFailure, "Init() fails");
+    }
+
+    InstallerWrapper::install(m_widgetPath, m_handle);
+
+    AddStep(&RunnableObjectStateTester::performTest);
+}
+
+RunnableObjectStateTester::~RunnableObjectStateTester()
+{
+    LogDebug("enter");
+    WRT::CoreModuleSingleton::Instance().Terminate();
+    InstallerWrapper::uninstall(m_handle);
+    elm_shutdown();
+}
+
+void RunnableObjectStateTester::performCheckBeforeLaunch()
+{
+    m_widget->CheckBeforeLaunch();
+}
+
+void RunnableObjectStateTester::performPrepareView()
+{
+    //this address is invalid but we use mock (may be problematic when implementation'll change)
+    Evas_Object * fakeWindowAddress = reinterpret_cast<Evas_Object*>(0x01);
+    m_widget->PrepareView(DPL::ToUTF8String(DPL::String()),
+            fakeWindowAddress);
+}
+
+void RunnableObjectStateTester::performShow()
+{
+    m_widget->Show();
+}
+
+void RunnableObjectStateTester::performHide()
+{
+    m_widget->Hide();
+}
+
+void RunnableObjectStateTester::performSuspend()
+{
+    m_widget->Suspend();
+}
+
+void RunnableObjectStateTester::performResume()
+{
+    m_widget->Resume();
+}
+
+void RunnableObjectStateTester::performReset()
+{
+    m_widget->Reset();
+}
+
+void RunnableObjectStateTester::performGetCurrentWebview()
+{
+    m_widget->GetCurrentWebview();
+}
+
+void RunnableObjectStateTester::performSetUserDelegates()
+{
+    WRT::UserDelegatesPtr dlgs(new WRT::UserDelegates);
+    dlgs->loadFinish = DPL::MakeDelegate(this, &RunnableObjectStateTester::loadFinishCallback);
+    m_widget->SetUserDelegates(dlgs);
+}
+
+void RunnableObjectStateTester::performBackward()
+{
+    m_widget->Backward();
+}
+
+void RunnableObjectStateTester::OnEventReceived(const NextStepEvent& /*event*/)
+{
+    NextStep();
+}
+
+void RunnableObjectStateTester::loadFinishCallback(Evas_Object* /*evas*/)
+{
+    LogDebug("enter");
+}
+
+void RunnableObjectStateTester::runTest(RunnableObjectStateTester::Test func)
+{
+    m_widget = WRT::CoreModuleSingleton::Instance().getRunnableWidgetObject(m_handle);
+
+    //as we know we uses specific implementation
+    WRT::RunnableWidgetObject * m_widget_impl = dynamic_cast<WRT::RunnableWidgetObject*>(m_widget.get());
+    Assert(m_widget_impl);
+    m_widget_impl->setViewModule(ViewModule::IViewModulePtr(new MockViewModule()));
+    m_widget_impl->setContextManagerFactoryMethod(WRT::makeContextManagerFactoryMethod<MockContextManager>());
+    if(!m_widget)
+    {
+        ThrowMsg(CoreModuleFailure, "getRunnableWidgetObject() fails");
+    }
+
+    m_func = func;
+    SwitchToStep(&RunnableObjectStateTester::performTest);
+    DPL::Event::ControllerEventHandler<NextStepEvent>::PostTimedEvent(NextStepEvent(), 1.0); //TODO: time hazard
+
+    elm_run(); //elm_run should be called instead of ecore_main_loop
+}
+
+void RunnableObjectStateTester::performTest()
+{
+    LogDebug("enter");
+
+    Try {
+        m_func(*this);
+    } Catch(DPL::Exception) {
+        LogDebug("Test broken not at condition to be checked. Check other tests");
+        LogDebug(_rethrown_exception.DumpToString());
+    }
+
+    Quit();
+    m_widget.reset();
+
+    LogDebug("leave");
+}
diff --git a/tests/widgets/common/src/mock/MockContextManager.cpp b/tests/widgets/common/src/mock/MockContextManager.cpp
new file mode 100644 (file)
index 0000000..38ed673
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file        MockContextManager.cpp
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Mock for view module
+ */
+#include "mock/MockContextManager.h"
+
+MockContextManager::MockContextManager(
+       const std::string& tizenAppId,
+       Ewk_Context* ewkContext,
+       ViewModule::IViewModulePtr viewModule) :
+       AbstractContextManager(tizenAppId, ewkContext, viewModule)
+{
+}
+
+MockContextManager::~MockContextManager()
+{
+}
+
+Ewk_Context* MockContextManager::getEwkContext() const
+{
+    return NULL;
+}
+
+void MockContextManager::handleLowMemory()
+{
+}
diff --git a/tests/widgets/common/src/mock/MockViewModule.cpp b/tests/widgets/common/src/mock/MockViewModule.cpp
new file mode 100644 (file)
index 0000000..bfc6374
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file        MockViewModule.cpp
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Mock for view module
+ */
+
+#include "mock/MockViewModule.h"
+
+MockViewModule::MockViewModule()
+{
+}
+
+bool MockViewModule::createWebView(Ewk_Context* /*context*/,
+                         Evas_Object* /*window*/)
+{
+    return true;
+}
+
+void MockViewModule::prepareView(WidgetModel *, const std::string &)
+{
+}
+
+void MockViewModule::showWidget()
+{
+}
+
+void MockViewModule::hideWidget()
+{
+}
+
+void MockViewModule::suspendWidget()
+{
+}
+
+void MockViewModule::resumeWidget()
+{
+}
+
+void MockViewModule::resetWidget()
+{
+}
+
+void MockViewModule::backward()
+{
+}
+
+void MockViewModule::reloadStartPage()
+{
+}
+
+Evas_Object* MockViewModule::getCurrentWebview()
+{
+    return NULL;
+}
+
+void MockViewModule::fireJavascriptEvent(int /*event*/, void* /*data*/)
+{
+}
+
+void MockViewModule::setUserCallbacks(const WRT::UserDelegatesPtr& /*cbs*/)
+{
+}
+
+void MockViewModule::checkSyncMessageFromBundle(
+      const char* /*name*/,
+      const char* /*body*/,
+      char** /*returnData*/)
+{
+}
+
+void MockViewModule::downloadData(const char* /*url*/)
+{
+}
+
+void MockViewModule::activateVibration(bool /*on*/, uint64_t /*time*/)
+{
+}
diff --git a/tests/widgets/files/CMakeLists.txt b/tests/widgets/files/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7d8474e
--- /dev/null
@@ -0,0 +1,22 @@
+# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+# @author      Tomasz Iwanek (t.iwanek@samsung.com)
+#
+
+SET(WRT_TESTS_GENERAL_WIDGETS_PATH "/opt/share/widget/tests/general/")
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/any.wgt
+        DESTINATION ${WRT_TESTS_GENERAL_WIDGETS_PATH})
diff --git a/tests/widgets/files/any.wgt b/tests/widgets/files/any.wgt
new file mode 100644 (file)
index 0000000..05b46b6
Binary files /dev/null and b/tests/widgets/files/any.wgt differ
diff --git a/uncrustify.cfg b/uncrustify.cfg
new file mode 100644 (file)
index 0000000..2bf1d96
--- /dev/null
@@ -0,0 +1,170 @@
+indent_align_string=true\r
+indent_braces=false\r
+indent_braces_no_func=false\r
+indent_brace_parent=false\r
+indent_namespace=false\r
+indent_extern=false\r
+indent_class=true\r
+indent_class_colon=false\r
+indent_else_if=false\r
+indent_func_call_param=false\r
+indent_func_def_param=false\r
+indent_func_proto_param=false\r
+indent_func_class_param=false\r
+indent_func_ctor_var_param=false\r
+indent_template_param=false\r
+indent_func_param_double=false\r
+indent_relative_single_line_comments=false\r
+indent_col1_comment=true\r
+indent_access_spec_body=false\r
+indent_paren_nl=false\r
+indent_comma_paren=false\r
+indent_bool_paren=false\r
+indent_square_nl=false\r
+indent_preserve_sql=false\r
+indent_align_assign=false\r
+sp_balance_nested_parens=false\r
+align_keep_tabs=false\r
+align_with_tabs=false\r
+align_on_tabstop=false\r
+align_number_left=false\r
+align_func_params=false\r
+align_same_func_call_params=false\r
+align_var_def_colon=false\r
+align_var_def_attribute=false\r
+align_var_def_inline=false\r
+align_right_cmt_mix=false\r
+align_on_operator=false\r
+align_mix_var_proto=false\r
+align_single_line_func=false\r
+align_single_line_brace=false\r
+align_nl_cont=false\r
+align_left_shift=true\r
+nl_collapse_empty_body=true\r
+nl_assign_leave_one_liners=false\r
+nl_class_leave_one_liners=false\r
+nl_enum_leave_one_liners=false\r
+nl_getset_leave_one_liners=false\r
+nl_func_leave_one_liners=false\r
+nl_if_leave_one_liners=false\r
+nl_multi_line_cond=true\r
+nl_multi_line_define=false\r
+nl_before_case=false\r
+nl_after_case=false\r
+nl_after_return=false\r
+nl_after_semicolon=true\r
+nl_after_brace_open=false\r
+nl_after_brace_open_cmt=false\r
+nl_after_vbrace_open=false\r
+nl_after_brace_close=false\r
+nl_define_macro=false\r
+nl_squeeze_ifdef=false\r
+nl_ds_struct_enum_cmt=false\r
+nl_ds_struct_enum_close_brace=false\r
+nl_create_if_one_liner=false\r
+nl_create_for_one_liner=false\r
+nl_create_while_one_liner=false\r
+ls_for_split_full=true\r
+ls_func_split_full=true\r
+nl_after_multiline_comment=false\r
+eat_blanks_after_open_brace=true\r
+eat_blanks_before_close_brace=true\r
+mod_pawn_semicolon=false\r
+mod_full_paren_if_bool=false\r
+mod_remove_extra_semicolon=true\r
+mod_sort_import=false\r
+mod_sort_using=false\r
+mod_sort_include=false\r
+mod_move_case_break=false\r
+mod_remove_empty_return=false\r
+cmt_indent_multi=true\r
+cmt_c_group=false\r
+cmt_c_nl_start=false\r
+cmt_c_nl_end=false\r
+cmt_cpp_group=false\r
+cmt_cpp_nl_start=false\r
+cmt_cpp_nl_end=false\r
+cmt_cpp_to_c=false\r
+cmt_star_cont=true\r
+cmt_multi_check_last=true\r
+cmt_insert_before_preproc=false\r
+pp_indent_at_level=false\r
+pp_region_indent_code=false\r
+pp_if_indent_code=false\r
+pp_define_at_level=false\r
+indent_columns=4\r
+indent_member=4\r
+indent_access_spec=-2\r
+code_width=80\r
+nl_max=2\r
+nl_before_access_spec=2\r
+cmt_width=80\r
+indent_with_tabs=0\r
+sp_arith=force\r
+sp_assign=force\r
+sp_enum_assign=force\r
+sp_pp_concat=remove\r
+sp_pp_stringify=remove\r
+sp_bool=force\r
+sp_compare=force\r
+sp_paren_brace=force\r
+sp_angle_paren=remove\r
+sp_before_sparen=force\r
+sp_inside_sparen=remove\r
+sp_after_sparen=force\r
+sp_sparen_brace=force\r
+sp_before_semi=remove\r
+sp_after_semi_for_empty=remove\r
+sp_before_square=remove\r
+sp_before_squares=remove\r
+sp_inside_square=remove\r
+sp_after_comma=force\r
+sp_before_comma=remove\r
+sp_after_class_colon=force\r
+sp_before_class_colon=force\r
+sp_before_case_colon=remove\r
+sp_inside_braces=add\r
+sp_inside_fparens=remove\r
+sp_inside_fparen=remove\r
+sp_func_call_paren=remove\r
+sp_func_class_paren=remove\r
+sp_else_brace=force\r
+sp_brace_else=force\r
+sp_catch_brace=force\r
+sp_brace_catch=force\r
+sp_try_brace=force\r
+sp_before_dc=remove\r
+sp_after_dc=remove\r
+sp_not=remove\r
+sp_inv=remove\r
+sp_addr=remove\r
+sp_member=remove\r
+sp_deref=remove\r
+sp_sign=remove\r
+sp_incdec=remove\r
+sp_cond_colon=force\r
+sp_cond_question=force\r
+sp_case_label=force\r
+nl_assign_brace=remove\r
+nl_if_brace=remove\r
+nl_brace_else=remove\r
+nl_elseif_brace=remove\r
+nl_else_brace=remove\r
+nl_else_if=remove\r
+nl_try_brace=remove\r
+nl_for_brace=remove\r
+nl_catch_brace=remove\r
+nl_brace_catch=remove\r
+nl_while_brace=remove\r
+nl_do_brace=remove\r
+nl_brace_while=remove\r
+nl_switch_brace=remove\r
+nl_namespace_brace=remove\r
+nl_class_brace=force\r
+nl_fdef_brace=force\r
+pos_class_comma=trail\r
+pos_class_colon=trail\r
+mod_full_brace_do=add\r
+mod_full_brace_for=add\r
+mod_full_brace_if=add\r
+mod_full_brace_while=add\r
diff --git a/uncrustify.sh b/uncrustify.sh
new file mode 100755 (executable)
index 0000000..f1edae0
--- /dev/null
@@ -0,0 +1 @@
+uncrustify -c uncrustify.cfg --no-backup `find . -regex "\(.*\.cpp\|.*\.h\|.*\.c\|.*\.cc\)" | grep -v "orm.h\|orm_generator.h"`