[Release] wrt_0.8.229
authorTaejeong Lee <taejeong.lee@samsung.com>
Tue, 18 Jun 2013 09:20:17 +0000 (18:20 +0900)
committerHoseon LEE <hoseon46.lee@samsung.com>
Sun, 29 Sep 2013 05:36:26 +0000 (14:36 +0900)
Change-Id: I78fcaa3a6bc537777e1f3888b32fd393cbfa27c5

22 files changed:
packaging/wrt.spec
src/CMakeLists.txt
src/api_new/CMakeLists.txt
src/api_new/ewk_context_manager.cpp
src/view/common/view_logic_storage_support.cpp
src/view/webkit/injected-bundle/CMakeLists.txt
src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp
src/view/webkit/injected-bundle/injected_bundle_uri_handling.h
src/view/webkit/injected-bundle/wrt-injected-bundle.cpp
src/view/webkit/view_logic.cpp
src/view/webkit/view_logic.h
src/wrt-client/CMakeLists.txt
src/wrt-client/process_pool/smack_labeling_support.cpp [new file with mode: 0644]
src/wrt-client/process_pool/smack_labeling_support.h [new file with mode: 0644]
src/wrt-client/window_data.cpp
src/wrt-client/window_data.h
src/wrt-client/wrt-client.cpp
src/wrt-client/wrt-client.h
src/wrt-launchpad-daemon/include/launchpad_util.h
src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h [new file with mode: 0644]
src/wrt-launchpad-daemon/legacy/preload.h
wrt_env.sh

index 8550da7..5b066f4 100644 (file)
@@ -1,7 +1,7 @@
 #git:framework/web/wrt
 Name:       wrt
 Summary:    web runtime
-Version:    0.8.227
+Version:    0.8.229
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
@@ -19,7 +19,6 @@ BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(ewebkit2)
 BuildRequires:  pkgconfig(appcore-efl)
 BuildRequires:  pkgconfig(openssl)
-BuildRequires:  pkgconfig(cert-svc)
 BuildRequires:  pkgconfig(dpl-efl)
 BuildRequires:  pkgconfig(libpcrecpp)
 BuildRequires:  pkgconfig(ecore)
@@ -30,6 +29,7 @@ BuildRequires:  pkgconfig(secure-storage)
 BuildRequires:  pkgconfig(pkgmgr)
 BuildRequires:  pkgconfig(libiri)
 BuildRequires:  pkgconfig(appsvc)
+BuildRequires:  pkgconfig(cert-svc)
 BuildRequires:  pkgconfig(cert-svc-vcore)
 BuildRequires:  pkgconfig(libsoup-2.4)
 BuildRequires:  pkgconfig(security-core)
@@ -47,6 +47,7 @@ BuildRequires:  pkgconfig(wrt-popup-ace-runner)
 BuildRequires:  pkgconfig(sysman)
 BuildRequires:  pkgconfig(app2sd)
 BuildRequires:  pkgconfig(capi-system-system-settings)
+BuildRequires:  pkgconfig(libsmack)
 BuildRequires:  libss-client-devel
 BuildRequires:  gettext
 BuildRequires:  edje-tools
index 7c402fd..205267c 100644 (file)
 # @version     1.0
 #
 
+# "smack-labeling-support-static" static library -------------------------------
+SET(SMACK_LABELING_SUPPORT_STATIC  "smack-labeling-support-static")
+PKG_CHECK_MODULES(SMACK_LABELING_SUPPORT_DEPS
+    dpl-efl
+    libsmack
+    REQUIRED
+)
+SET(SMACK_LABELING_SUPPORT_SOURCES
+    ${PROJECT_SOURCE_DIR}/src/wrt-client/process_pool/smack_labeling_support.cpp
+    )
+SET(SMACK_LABELING_SUPPORT_INCLUDES
+    ${PROJECT_SOURCE_DIR}/src/wrt-client/process_pool/
+   )
+INCLUDE_DIRECTORIES(
+    ${SMACK_LABELING_SUPPORT_INCLUDES}
+    ${SMACK_LABELING_SUPPORT_DEPS_INCLUDE_DIRS}
+    )
+ADD_LIBRARY(${SMACK_LABELING_SUPPORT_STATIC} STATIC
+    ${SMACK_LABELING_SUPPORT_SOURCES}
+    )
+TARGET_LINK_LIBRARIES(${SMACK_LABELING_SUPPORT_STATIC}
+    ${SMACK_LABELING_SUPPORT_DEPS_LIBRARIES}
+    )
+# ------------------------------------------------------------------------------
+
 #it is here, so no INCLUDE_DIRS and DEFINITIONS are passed there
 ADD_SUBDIRECTORY(view)
 
-
 SET(WRT_SRC_DIR
    ${PROJECT_SOURCE_DIR}/src
    )
index f5af14a..34b6668 100644 (file)
@@ -36,6 +36,7 @@ PKG_CHECK_MODULES(CORE_MODULE_DEP
 PKG_CHECK_MODULES(SYS_CORE_MODULE_DEP
     ewebkit2
     libprivilege-control
+    cert-svc
     REQUIRED
 )
 
index 9d3db72..3884276 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <string>
+#include <cert-service.h>
 #include <vconf.h>
 #include <ewk_context.h>
 #include <dpl/log/log.h>
@@ -37,7 +38,6 @@
 namespace WRT {
 
 static const std::string bundlePath("/usr/lib/libwrt-injected-bundle.so");
-static const std::string caCertPath("/opt/usr/share/certs/ca-certificate.crt");
 
 EwkContextManager::EwkContextManager(
         const std::string& tizenAppId,
@@ -93,7 +93,12 @@ bool EwkContextManager::initialize()
     setNetworkProxy();
 
     LogInfo("ewk_context_certificate_file_set() was called.");
-    ewk_context_certificate_file_set(m_ewkContext, caCertPath.c_str());
+    const char* caCertPath = cert_svc_get_certificate_crt_file_path();
+    if (caCertPath) {
+        ewk_context_certificate_file_set(m_ewkContext, caCertPath);
+    } else {
+        LogError("cert path is null");
+    }
 
     // set local stroage database path
     WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(m_appId));
@@ -101,12 +106,6 @@ bool EwkContextManager::initialize()
             m_ewkContext,
             dao.getPrivateLocalStoragePath().c_str());
 
-    // memory saving mode
-    //ewk_context_memory_saving_mode_set(
-    //       m_ewkContext,
-    //       static_cast<WrtDB::SettingsType>(result) ==
-    //        WrtDB::SETTINGS_TYPE_ON ? EINA_TRUE : EINA_FALSE);
-
     ewk_context_tizen_extensible_api_set(
         m_ewkContext,
         EWK_EXTENSIBLE_API_MEDIA_STREAM_RECORD,
@@ -289,7 +288,6 @@ void EwkContextManager::messageFromInjectedBundleCallback(
         void* clientInfo)
 {
     LogDebug("enter");
-    LogDebug("did recive message: " << name);
 
     EwkContextManager* This = static_cast<EwkContextManager*>(clientInfo);
     if (returnData) {
@@ -302,7 +300,6 @@ void EwkContextManager::messageFromInjectedBundleCallback(
 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);
index ed720bd..c6cba82 100644 (file)
@@ -40,6 +40,7 @@ static int removeFile(const char* path, const struct stat* /*sb*/, int tflag)
 {
     if (path == NULL) {
         LogError("Wrong input path");
+        return 0;
     }
     LogDebug(path);
     std::string inputPath = path;
index ce05e33..45d1215 100644 (file)
@@ -49,7 +49,10 @@ SET(INJECTED_BUNDLE_INCLUDES
 )
 
 ADD_DEFINITIONS(${INJECTED_BUNDLE_DEP_CFLAGS})
-INCLUDE_DIRECTORIES(${INJECTED_BUNDLE_INCLUDES})
+INCLUDE_DIRECTORIES(
+    ${INJECTED_BUNDLE_INCLUDES}
+    ${SMACK_LABELING_SUPPORT_INCLUDES}
+    )
 
 ADD_LIBRARY(${TARGET_INJECTED_BUNDLE_LIB} SHARED
     ${INJECTED_BUNDLE_SOURCES}
@@ -61,6 +64,7 @@ TARGET_LINK_LIBRARIES(
     ${TARGET_WRT_ENGINE_STATIC}
     ${TARGET_PLUGIN_MODULE_LIB}
     ${PROF_LIB}
+    ${SMACK_LABELING_SUPPORT_STATIC}
 )
 
 # for encryption
index b2ea952..a2aaae9 100644 (file)
@@ -119,7 +119,7 @@ bool checkWARP(const char *url, const DPL::String& tizenId)
 
 bool checkWhitelist(const char *url)
 {
-    LogInfo("Check WhiteList");
+    LogInfo("Check WhiteList for uri: " << url);
     if (url == NULL) {
         return true;
     }
@@ -348,11 +348,20 @@ bool processMainResource(const DPL::String& inputURI,
     return true;
 }
 
-bool processURIForPlugin(const char* url)
+bool processURIForPlugin(const char* url, const DPL::String &tizenId)
 {
     if (!checkWhitelist(url)) {
         return false;
     }
+    DPL::OptionalString found =
+        W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
+            tizenId,
+            DPL::FromUTF8String(std::string(url)));
+    if (found.IsNull()) {
+        LogDebug("Path not found within current locale in current widget");
+        return false;
+    }
+
     return true;
 }
 
index f7705b9..73bc23a 100644 (file)
@@ -37,7 +37,7 @@ bool processURI(const std::string& inputURI,
 bool processMainResource(const DPL::String& inputURI,
                 const DPL::String& tizenId,
                 WrtDB::WidgetSecurityModelVersion m_securityModelVersion);
-bool processURIForPlugin(const char* url);
+bool processURIForPlugin(const char* url, const DPL::String &tizenId);
 DPL::OptionalString localizeURI(const DPL::String& inputURI,
                                 const DPL::String& tizenId);
 std::string localizeURI(const std::string& inputURI, const std::string& tizenId);
index 705c0c8..9ddd6d4 100644 (file)
@@ -68,6 +68,7 @@
 
 #include <sys/resource.h>
 #include <privilege-control.h>
+#include <smack_labeling_support.h>
 
 // URI localization on WebProcess side
 #include "injected_bundle_uri_handling.h"
@@ -461,6 +462,12 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
                         GetUserWidgetExecPath() + "/" + tzAppId;
                 }
 
+                LogDebug("set_app_smack_label(" << appPath << ")");
+                if (set_app_smack_label(appPath.c_str()) != 0)
+                {
+                    LogError("set_app_smack_label() failed");
+                }
+
                 LogDebug("set_app_privilege(" << appPath << ")");
                 set_app_privilege(tzPkgId.c_str(), PRIVILEGE_APP_TYPE, appPath.c_str());
             }
@@ -646,7 +653,9 @@ void Bundle::didCommitLoadForFrameCallback(
     }
 
     std::string urlStr = toString(url);
-    if (InjectedBundleURIHandling::processURIForPlugin(urlStr.c_str())) {
+    if (InjectedBundleURIHandling::processURIForPlugin(urlStr.c_str(),
+                                                       This->m_widgetTizenId))
+    {
         LogDebug("start plugin");
         if(This->m_pageGlobalContext.find(page) != This->m_pageGlobalContext.end())
         {
index 3ed737d..75fdb66 100644 (file)
@@ -172,7 +172,11 @@ std::map<const std::string,
     { "mediacontrol,rotate,vertical",
       &ViewLogic::mediacontrolRotateVertical },
     { "mediacontrol,rotate,exit",
-      &ViewLogic::mediacontrolRotateExit }
+      &ViewLogic::mediacontrolRotateExit },
+    { "popup,reply,wait,start",
+      &ViewLogic::popupReplyWaitStart },
+    { "popup,reply,wait,finish",
+      &ViewLogic::popupReplyWaitFinish },
 };
 
 ViewLogic::ViewLogic() :
@@ -191,6 +195,7 @@ ViewLogic::ViewLogic() :
     m_deferredRotateAngle(
         ViewModule::OrientationSupport::DEFERRED_ORIENTATION_EMPTY),
     m_orientationThresholdTimer(NULL),
+    m_isPopupReplyWait(false),
     m_appsSupport(new ViewModule::AppsSupport()),
     m_vibrationSupport(new ViewModule::VibrationSupport())
 {
@@ -342,8 +347,6 @@ void ViewLogic::suspendWidget()
         }
     }
 
-    evas_object_focus_set(m_currentEwkView, EINA_FALSE);
-
     // call user callback
     if (!m_cbs->suspend.empty()) {
         m_cbs->suspend(true);
@@ -368,7 +371,6 @@ void ViewLogic::resumeWidget()
      *  elm_win_raise(m_window);
      * }
      */
-    evas_object_focus_set(m_currentEwkView, EINA_TRUE);
 
     // call user callback
     if (!m_cbs->resume.empty()) {
@@ -380,35 +382,53 @@ void ViewLogic::resetWidget()
 {
     LogInfo("Resetting Widget");
 
-    // destory all webview
-    while (!m_ewkViewList.empty()) {
-        LogInfo("pop webview: " << m_ewkViewList.back());
-        removeEwkView(m_ewkViewList.back());
-    }
-    m_ewkViewList.clear();
+    // handling case of WebProcess is locked
+    if (m_isPopupReplyWait) {
+        // resume web application
+        LogDebug("WebProcess is locked");
+        if (m_currentEwkView) {
+            setEwkViewVisible(m_currentEwkView);
+            if (!m_isBackgroundSupport) {
+                resumeWebkit(m_currentEwkView);
+            }
+        }
+        // webview activated
+        elm_win_activate(m_window);
 
-    // create new webview
-    createEwkView(evas_object_evas_get(m_window));
-    ewkClientInit(m_currentEwkView);
-    prepareEwkView(m_currentEwkView);
+        // call user callback
+        if (!m_cbs->reset.empty()) {
+            m_cbs->reset(false);
+        }
+    } else {
+        // reset web application
+        // destory all webview
+        while (!m_ewkViewList.empty()) {
+            LogInfo("pop webview: " << m_ewkViewList.back());
+            removeEwkView(m_ewkViewList.back());
+        }
+        m_ewkViewList.clear();
 
-    // check if current url is service url for this tizen service
-    std::string url =
-        ViewModule::UriSupport::getUri(m_model, m_startUrl);
+        // create new webview
+        createEwkView(evas_object_evas_get(m_window));
+        ewkClientInit(m_currentEwkView);
+        prepareEwkView(m_currentEwkView);
 
-    initializePluginLoading();
+        // check if current url is service url for this tizen service
+        std::string url =
+            ViewModule::UriSupport::getUri(m_model, m_startUrl);
 
-    // webview activated
-    ewk_view_url_set(m_currentEwkView, url.c_str());
-    elm_win_activate(m_window);
-    evas_object_focus_set(m_currentEwkView, EINA_TRUE);
+        initializePluginLoading();
+        // webview activated
+        ewk_view_url_set(m_currentEwkView, url.c_str());
+        elm_win_activate(m_window);
 
-    // call user callback
-    if (!m_cbs->reset.empty()) {
-        m_cbs->reset(true);
-    }
-    if (!m_cbs->bufferSet.empty()) {
-        m_cbs->bufferSet(m_currentEwkView);
+        // call user callback
+        if (!m_cbs->reset.empty()) {
+            m_cbs->reset(true);
+        }
+        if (!m_cbs->bufferSet.empty()) {
+            m_cbs->bufferSet(m_currentEwkView);
+        }
     }
 }
 
@@ -898,7 +918,6 @@ void ViewLogic::loadFinishedCallback(
     LogDebug("loadFinishedCallback called");
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
-    evas_object_focus_set(This->m_currentEwkView, EINA_TRUE);
 
     // Fill id/password
     const char* url = ewk_view_url_get(This->m_currentEwkView);
@@ -2263,6 +2282,26 @@ Eina_Bool ViewLogic::orientationThresholdTimerCallback(void* data)
     return ECORE_CALLBACK_CANCEL;
 }
 
+void ViewLogic::popupReplyWaitStart(void* data,
+                                    Evas_Object* /*obj*/,
+                                    void* /*eventInfo*/)
+{
+    LogInfo("called");
+    Assert(data);
+    ViewLogic* This = static_cast<ViewLogic*>(data);
+    This->m_isPopupReplyWait = true;
+}
+
+void ViewLogic::popupReplyWaitFinish(void* data,
+                                     Evas_Object* /*obj*/,
+                                     void* /*eventInfo*/)
+{
+    LogInfo("called");
+    Assert(data);
+    ViewLogic* This = static_cast<ViewLogic*>(data);
+    This->m_isPopupReplyWait = false;
+}
+
 void ViewLogic::requestUrlBlocked(const std::string& blockedUrl)
 {
     LogInfo("enter");
index bc9bd80..3826a7e 100644 (file)
@@ -266,6 +266,12 @@ class ViewLogic : public ViewModule::IViewModule
     static void mediacontrolRotateExit(void* data,
                                        Evas_Object* obj,
                                        void* eventInfo);
+    static void popupReplyWaitStart(void* data,
+                                    Evas_Object* obj,
+                                    void* eventInfo);
+    static void popupReplyWaitFinish(void* data,
+                                     Evas_Object* obj,
+                                     void* eventInfo);
 
 #ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
     static int appServiceCallerIsKilled(void *data);
@@ -320,6 +326,7 @@ class ViewLogic : public ViewModule::IViewModule
     int m_rotateAngle;
     int m_deferredRotateAngle;
     Ecore_Timer* m_orientationThresholdTimer;
+    bool m_isPopupReplyWait;
 
     std::unique_ptr<SchemeSupport> m_schemeSupport;
     std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
index 15f0fb9..b3b51a8 100644 (file)
@@ -39,6 +39,7 @@ INCLUDE_DIRECTORIES(
     ${PROJECT_SOURCE_DIR}/src/api_new
     ${PROJECT_SOURCE_DIR}/src/wrt-launchpad-daemon/include
     ${CLIENT_DEP_INCLUDE_DIRS}
+    ${SMACK_LABELING_SUPPORT_INCLUDES}
 )
 
 ADD_EXECUTABLE(${TARGET_WRT_CLIENT}
@@ -48,6 +49,7 @@ ADD_EXECUTABLE(${TARGET_WRT_CLIENT}
 TARGET_LINK_LIBRARIES(${TARGET_WRT_CLIENT}
     ${CLIENT_DEP_LIBRARIES}
     ${TARGET_CORE_MODULE_LIB}
+    ${SMACK_LABELING_SUPPORT_STATIC}
     "-pie"
 )
 
diff --git a/src/wrt-client/process_pool/smack_labeling_support.cpp b/src/wrt-client/process_pool/smack_labeling_support.cpp
new file mode 100644 (file)
index 0000000..8833960
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * 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    smack_labeling_support.cpp
+ * @author  Tae-Jeong Lee (taejeong.lee@samsung.com)
+ * @version 0.1
+ * @brief   API to support smack labeling for whole threads in a process.
+ */
+
+#include "smack_labeling_support.h"
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/smack.h>
+#include <dirent.h>
+#include <assert.h>
+#include <dpl/log/log.h>
+
+#define SMACK_LABEL_LEN 255
+#define FILE_MAX_LEN    1024
+#define MAX_RETRY_CNT   1000
+#define UID_ROOT        0
+
+static char s_smack_label[SMACK_LABEL_LEN + 1] = {0,};
+static int  s_waiting_task_cnt = 0;
+
+static int smack_set_label_for_tid(const char *label)
+{
+    int len, fd, ret;
+    char curren_path[FILE_MAX_LEN + 1] = {0,};
+
+    len = strnlen(label, SMACK_LABEL_LEN + 1);
+
+    if (len > SMACK_LABEL_LEN)
+    {
+        return -1;
+    }
+
+    snprintf(curren_path, sizeof(curren_path), "/proc/%d/attr/current", (int)syscall(__NR_gettid));
+
+    fd = open(curren_path, O_WRONLY);
+
+    if (fd < 0)
+    {
+        return -1;
+    }
+
+    ret = write(fd, label, len);
+    close(fd);
+
+    return (ret < 0) ? -1 : 0;
+}
+
+static void SIGUSR1_handler(int /*signo*/)
+{
+    if (smack_set_label_for_tid(s_smack_label) != 0)
+    {
+        LogError("## [tid:" << syscall(__NR_gettid) << "] smack_set_label_for_tid() failed! ##");
+    }
+    s_waiting_task_cnt--;
+}
+
+static int set_SIGUSR1_handler()
+{
+    if (signal(SIGUSR1, SIGUSR1_handler) == SIG_ERR)
+    {
+        LogError("## signal(SIGUSR1, SIGUSR1_handler) failed! ##");
+        return -1;
+    }
+
+    return 0;
+}
+
+static int set_SIGUSR1_to_default()
+{
+    if (signal(SIGUSR1, SIG_DFL) == SIG_ERR)
+    {
+        LogError("## signal(SIGUSR1, SIG_ERR) failed! ##");
+        return -1;
+    }
+
+    return 0;
+}
+
+static int send_SIGUSR1_to_threads()
+{
+    int ret;
+    DIR *dir;
+    struct dirent entry, *result;
+    char proc_self_task_path[FILE_MAX_LEN + 1] = {0, };
+
+    sprintf(proc_self_task_path, "/proc/self/task");
+
+    dir = opendir(proc_self_task_path);
+
+    if (dir)
+    {
+        for (ret = readdir_r(dir, &entry, &result);
+             result != NULL && ret == 0;
+             ret = readdir_r(dir, &entry, &result))
+        {
+            if (strncmp(entry.d_name, ".", 2) == 0 ||
+                strncmp(entry.d_name, "..", 3) == 0)
+            {
+                continue;
+            }
+
+            s_waiting_task_cnt++;
+            if (syscall(__NR_tkill, atoi(entry.d_name), SIGUSR1) != 0)
+            {
+                LogError("## tkill(" << atoi(entry.d_name) << "SIGUSR1) failed! ##");
+                s_waiting_task_cnt--;
+            }
+        }
+
+        closedir(dir);
+    }
+    else
+    {
+        LogError("## opendir(\"/proc/self/task\") failed! ##");
+        return -1;
+    }
+
+    return 0;
+}
+
+int set_app_smack_label(const char* app_path)
+{
+    assert(s_waiting_task_cnt == 0);
+
+    if (UID_ROOT != getuid() || app_path == NULL)
+    {
+        LogError("## parameter error! ##");
+        return -1;
+    }
+
+    // set SIGUSR1 signal handler
+    if (set_SIGUSR1_handler() != 0)
+    {
+        return -1;
+    }
+
+    // get smack label from app_path
+    char *smack_label = NULL;
+
+    if (smack_lgetlabel(app_path, &smack_label, SMACK_LABEL_EXEC) != 0)
+    {
+        LogError("## smack_lgetlabel() failed! ##");
+        goto err_set_app_smack_label;
+    }
+
+    strncpy(s_smack_label, smack_label, sizeof(s_smack_label));
+
+    if (send_SIGUSR1_to_threads() != 0)
+    {
+        LogError("## send_SIGUSR1_to_threads() timeout! ##");
+        goto err_set_app_smack_label;
+    }
+
+    // wait for labeling on each tasks
+    int i;
+
+    for (i=0; s_waiting_task_cnt && i < MAX_RETRY_CNT; i++)
+    {
+        usleep(100); // 0.1ms
+    }
+
+    if (i == MAX_RETRY_CNT)
+    {
+        LogError("## set_app_smack_label() timeout! ##");
+    }
+
+    // set SIGUSR1 signal defualt handler
+    set_SIGUSR1_to_default();
+
+    return 0;
+
+err_set_app_smack_label:
+    s_waiting_task_cnt = 0;
+    set_SIGUSR1_to_default();
+
+    return -1;
+}
+
+
diff --git a/src/wrt-client/process_pool/smack_labeling_support.h b/src/wrt-client/process_pool/smack_labeling_support.h
new file mode 100644 (file)
index 0000000..09ef1a5
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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    smack_labeling_support.h
+ * @author  Tae-Jeong Lee (taejeong.lee@samsung.com)
+ * @version 0.1
+ * @brief   API to support smack labeling for whole threads in a process.
+ */
+
+#ifndef SMACK_LABELING_SUPPORT_H
+#define SMACK_LABELING_SUPPORT_H
+
+int set_app_smack_label(const char* app_path);
+
+#endif // SMACK_LABELING_SUPPORT_H
index acac622..1be14b6 100644 (file)
@@ -94,6 +94,8 @@ void WindowData::init()
     evas_object_show(m_navigation);
     m_user_layout = createUserLayout(m_navigation);
     evas_object_show(m_user_layout);
+    m_focus = createFocus(m_user_layout);
+    evas_object_show(m_focus);
     m_progressbar = createProgressBar(m_win, m_user_layout);
     evas_object_show(m_progressbar);
 
@@ -101,14 +103,15 @@ void WindowData::init()
     m_initialized = true;
 }
 
-void WindowData::setEvasObjectForLayout(Evas_Object* evas_object)
+void WindowData::setEvasObjectForLayout(Evas_Object* obj)
 {
-    elm_object_content_set(m_conformant, evas_object);
+    elm_object_part_content_set(m_focus, ELM_SWALLOW_CONTENT, obj);
+    elm_object_focus_set(m_focus, EINA_TRUE);
 }
 
 void WindowData::unsetEvasObjectForLayout()
 {
-    elm_object_content_unset(m_conformant);
+    elm_object_part_content_unset(m_focus, ELM_SWALLOW_CONTENT);
 }
 
 void WindowData::toggleIndicator(bool fullscreen)
@@ -248,10 +251,25 @@ Evas_Object* WindowData::createUserLayout(Evas_Object* parent)
             NULL);
     ADD_PROFILING_POINT("elm_naviframe_item_push", "stop");
     elm_naviframe_item_title_visible_set(naviIt, EINA_FALSE);
-
     return layout;
 }
 
+Evas_Object* WindowData::createFocus(Evas_Object* parent)
+{
+    Assert(parent != NULL && "Parent for Focus is null");
+    // ewkview isn't elementary widget style. This is reason why ewkview focus
+    // doesn't restore after focus-out and focus-in. To support focus restore
+    // for ewkview, WRT add selectable elementary(button) to manage focus
+    Evas_Object* focus = elm_button_add(parent);
+    elm_object_style_set(focus, "focus");
+    elm_object_part_content_set(parent, ELM_SWALLOW_CONTENT, focus);
+    evas_object_size_hint_weight_set(focus,
+                                     EVAS_HINT_EXPAND,
+                                     EVAS_HINT_EXPAND);
+    evas_object_size_hint_align_set(focus, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    return focus;
+}
+
 Evas_Object* WindowData::createProgressBar(Evas_Object* window, Evas_Object* parent)
 {
     Assert(parent != NULL && "Parent is null");
@@ -342,6 +360,23 @@ void* WindowData::userlayoutCallbackDel(
     return evas_object_event_callback_del(m_user_layout, event, callBack);
 }
 
+void WindowData::focusCallbackAdd(
+    const char* event,
+    CallbackType callback,
+    const void* data)
+{
+    Assert(m_focus != NULL && "m_focus is null");
+    evas_object_smart_callback_add(m_focus, event, callback, data);
+}
+
+void* WindowData::focusCallbackDel(
+    const char* event,
+    CallbackType callback)
+{
+    Assert(m_focus != NULL && "m_focus is null");
+    return evas_object_smart_callback_del(m_focus, event, callback);
+}
+
 void WindowData::emitSignalForUserLayout(
     const char* emission, const char* source)
 {
index a45c8a3..44e5eeb 100644 (file)
@@ -90,6 +90,13 @@ class WindowData : private DPL::Noncopyable
     void* userlayoutCallbackDel(
         const Evas_Callback_Type event,
         EvasCallbackType callback);
+    void focusCallbackAdd(
+        const char* event,
+        CallbackType callback,
+        const void* data);
+    void* focusCallbackDel(
+        const char* event,
+        CallbackType callback);
     void emitSignalForUserLayout(
         const char* emission,
         const char* source);
@@ -109,6 +116,7 @@ class WindowData : private DPL::Noncopyable
     Evas_Object* m_conformant;
     Evas_Object* m_platform_layout;
     Evas_Object* m_navigation;
+    Evas_Object* m_focus;
     Evas_Object* m_floatBackButton;
     Evas_Object* m_progressbar;
     Evas_Object* m_ctxpopup;
@@ -120,6 +128,7 @@ class WindowData : private DPL::Noncopyable
     Evas_Object* createPlatformLayout(Evas_Object* parent);
     Evas_Object* createNavigationBar(Evas_Object* parent);
     Evas_Object* createUserLayout(Evas_Object* parent);
+    Evas_Object* createFocus(Evas_Object* parent);
     Evas_Object* createProgressBar(Evas_Object* window, Evas_Object* parent);
     Evas_Object* createCtxPopup(Evas_Object* parent);
 
index 7429412..581900b 100644 (file)
@@ -37,9 +37,8 @@
 #include <vconf.h>
 #include "auto_rotation_support.h"
 
-#include "process_pool.h"
-#include "menu_db_util.h"
-#include "launchpad_util.h"
+#include <process_pool.h>
+#include <process_pool_launchpad_util.h>
 #include <appsvc.h>
 
 #include "client_service_support.h"
@@ -57,7 +56,6 @@ const std::string VIEWMODE_TYPE_MAXIMIZED = "maximized";
 const std::string VIEWMODE_TYPE_WINDOWED = "windowed";
 char const* const ELM_SWALLOW_CONTENT = "elm.swallow.content";
 const char* const BUNDLE_PATH = "/usr/lib/libwrt-injected-bundle.so";
-const char* const caCertPath = "/opt/usr/share/certs/ca-certificate.crt";
 const char* const MESSAGE_NAME_INITIALIZE = "ToInjectedBundle::INIT";
 
 // process pool
@@ -411,6 +409,15 @@ void WrtClient::loadFinishCallback(Evas_Object* webview)
     delete debug;
 }
 
+void WrtClient::resetCallback(bool result)
+{
+    if (!result) {
+        LogDebug("Fail to handle reset event");
+        // free bundle data
+        ApplicationDataSingleton::Instance().freeBundle();
+    }
+}
+
 void WrtClient::progressStartedCallback()
 {
     if (m_settingList->getProgressBarPresence() == ProgressBar_Enable ||
@@ -562,6 +569,8 @@ void WrtClient::launchStep()
     //you can't show window with splash screen before PrepareView
     //ewk_view_add_with_context() in viewLogic breaks window
     m_windowData->init();
+    m_windowData->focusCallbackAdd("focused", focusedCallback, this);
+    m_windowData->focusCallbackAdd("unfocused", unfocusedCallback, this);
 
     WrtDB::WidgetLocalizedInfo localizedInfo =
         W3CFileLocalization::getLocalizedInfo(m_dao);
@@ -590,6 +599,7 @@ void WrtClient::launchStep()
     cbs->progress = DPL::MakeDelegate(this, &WrtClient::loadProgressCallback);
     cbs->progressFinish = DPL::MakeDelegate(this, &WrtClient::progressFinishCallback);
     cbs->loadFinish = DPL::MakeDelegate(this, &WrtClient::loadFinishCallback);
+    cbs->reset = DPL::MakeDelegate(this, &WrtClient::resetCallback);
     cbs->bufferSet = DPL::MakeDelegate(this, &WrtClient::setLayout);
     cbs->bufferUnset = DPL::MakeDelegate(this, &WrtClient::unsetLayout);
     cbs->webkitExit = DPL::MakeDelegate(this, &WrtClient::webkitExitCallback);
@@ -836,11 +846,7 @@ 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);
-
+    m_windowData->setEvasObjectForLayout(newBuffer);
     evas_object_show(newBuffer);
 }
 
@@ -849,9 +855,7 @@ 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);
+    m_windowData->unsetEvasObjectForLayout();
 }
 
 void WrtClient::shutdownStep()
@@ -872,6 +876,8 @@ void WrtClient::shutdownStep()
     if (m_initialized) {
         m_initialized = false;
     }
+    m_windowData->focusCallbackDel("focused", focusedCallback);
+    m_windowData->focusCallbackDel("unfocused", unfocusedCallback);
     m_windowData.reset();
     Quit();
 }
@@ -888,6 +894,26 @@ void WrtClient::autoRotationCallback(void* data, Evas_Object* obj, void* /*event
     This->autoRotationSetOrientation(obj);
 }
 
+void WrtClient::focusedCallback(void* data,
+                                Evas_Object* /*obj*/,
+                                void* /*eventInfo*/)
+{
+    LogInfo("entered");
+    Assert(data);
+    WrtClient* This = static_cast<WrtClient*>(data);
+    elm_object_focus_set(This->m_widget->GetCurrentWebview(), EINA_TRUE);
+}
+
+void WrtClient::unfocusedCallback(void* data,
+                                Evas_Object* /*obj*/,
+                                void* /*eventInfo*/)
+{
+    LogInfo("entered");
+    Assert(data);
+    WrtClient* This = static_cast<WrtClient*>(data);
+    elm_object_focus_set(This->m_widget->GetCurrentWebview(), EINA_FALSE);
+}
+
 void WrtClient::autoRotationSetOrientation(Evas_Object* obj)
 {
     LogInfo("entered");
@@ -971,7 +997,7 @@ static Eina_Bool proces_pool_fd_handler(void* /*data*/, Ecore_Fd_Handler *handle
 
             ecore_main_fd_handler_del(handler);
 
-            __wrt_launchpad_main_loop(pkt, app_argv[0], &app_argc, &app_argv);
+            process_pool_launchpad_main_loop(pkt, app_argv[0], &app_argc, &app_argv);
 
             free(pkt);
         }
@@ -1100,6 +1126,7 @@ int main(int argc,
                 s_preparedEwkContext,
                 MESSAGE_NAME_INITIALIZE,
                 tizenId.c_str());
+
         }
         else
         {
index 871edde..6f5c238 100644 (file)
@@ -87,6 +87,12 @@ class WrtClient :
     static int appcoreLowMemoryCallback(void* data);
     static int languageChangedCallback(void *data);
     static void autoRotationCallback(void* data, Evas_Object* obj, void* event);
+    static void focusedCallback(void* data,
+                                Evas_Object* obj,
+                                void* eventInfo);
+    static void unfocusedCallback(void* data,
+                                  Evas_Object* obj,
+                                  void* eventInfo);
 
     //view-mode
     void setInitialViewMode();
@@ -111,6 +117,7 @@ class WrtClient :
     void launchStep();
     void shutdownStep();
     void loadFinishCallback(Evas_Object* webview);
+    void resetCallback(bool result);
     void progressStartedCallback();
     void loadProgressCallback(Evas_Object* webview, double value);
     void progressFinishCallback();
index 7df4776..26edc7e 100644 (file)
@@ -51,11 +51,8 @@ _static_ 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);
 _static_ void   __set_oom();
 _static_ void   __set_env(app_info_from_db * menu_info, bundle * kb);
-_static_ int    __wrt_prepare_exec(const char *pkg_name, const char *app_path, app_info_from_db * menu_info, bundle * kb);
-_static_ void   __wrt_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv);
 
 // Implementation
-
 _static_ char** __create_argc_argv(bundle * kb, int *margc)
 {
     char **argv;
@@ -297,114 +294,4 @@ _static_ void __set_env(app_info_from_db * menu_info, bundle * kb)
     }
 }
 
-_static_ int __wrt_prepare_exec(const char *pkg_name,
-                            const char *app_path, app_info_from_db * menu_info,
-                            bundle * kb)
-{
-    const char *file_name;
-    char process_name[WRT_AUL_PR_NAME];
-
-    /* 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 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', WRT_AUL_PR_NAME);
-    snprintf(process_name, WRT_AUL_PR_NAME, "%s", file_name);
-    prctl(PR_SET_NAME, process_name);
-
-    /* SET ENVIROMENT*/
-    __set_env(menu_info, kb);
-
-    return 0;
-}
-
-_static_ void __wrt_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv)
-
-{
-    bundle *kb = NULL;
-    app_info_from_db *menu_info = NULL;
-
-    const char *pkg_name = NULL;
-    const char *app_path = NULL;
-
-    kb = bundle_decode(pkt->data, pkt->len);
-    if (!kb) {
-        _E("bundle decode error");
-        exit(-1);
-    }
-
-    pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
-    SECURE_LOGD("pkg name : %s", pkg_name);
-
-    menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
-    if (menu_info == NULL) {
-        _D("such pkg no found");
-        exit(-1);
-    }
-
-    app_path = _get_app_path(menu_info);
-
-    if (app_path == NULL) {
-        _E("app_path is NULL");
-        exit(-1);
-    }
-
-    if (app_path[0] != '/') {
-        _E("app_path is not absolute path");
-        exit(-1);
-    }
-
-    __modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info, pkt->cmd);
-    pkg_name = _get_pkgname(menu_info);
-    SECURE_LOGD("pkg name : %s", pkg_name);
-
-    __wrt_prepare_exec(pkg_name, app_path, menu_info, kb);
-
-    if (out_app_path != NULL && out_argc != NULL && out_argv != NULL)
-    {
-        int i;
-
-        sprintf(out_app_path, "%s", app_path);
-
-        *out_argv = __create_argc_argv(kb, out_argc);
-        (*out_argv)[0] = out_app_path;
-
-        for (i = 0; i < *out_argc; i++)
-        {
-            _D("input argument %d : %s##", i, (*out_argv)[i]);
-        }
-    }
-    else
-    {
-        exit(-1);
-    }
-
-
-#if 0 // intentional
-    if (menu_info != NULL) {
-        _free_app_info_from_db(menu_info);
-    }
-
-    if (kb != NULL) {
-        bundle_free(kb);
-    }
-#endif
-}
-
 #endif // __LAUNCHPAD_UTIL_H_
diff --git a/src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h b/src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h
new file mode 100644 (file)
index 0000000..0026e2b
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * 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    process_pool_launchpad_util.h
+ * @author  Tae-Jeong Lee (taejeong.lee@samsung.com)
+ * @version 0.1
+ * @brief   Api library to support launchpad operation.
+ */
+
+#ifndef __PROCESS_POOL_LAUNCHPAD_UTIL_H_
+#define __PROCESS_POOL_LAUNCHPAD_UTIL_H_
+
+#include <launchpad_util.h>
+#include <smack_labeling_support.h>
+
+// Prototype
+_static_ int    __process_pool_prepare_exec(const char *pkg_name, const char *app_path, app_info_from_db * menu_info, bundle * kb);
+_static_ void   process_pool_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv);
+
+// Implementation
+_static_ int __process_pool_prepare_exec(const char *pkg_name,
+                            const char *app_path, app_info_from_db * menu_info,
+                            bundle * kb)
+{
+    const char *file_name;
+    char process_name[WRT_AUL_PR_NAME];
+
+    /* 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_app_smack_label(app_path) != 0)
+    {
+        _E("set_app_smack_label() failed");
+    }
+
+    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 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', WRT_AUL_PR_NAME);
+    snprintf(process_name, WRT_AUL_PR_NAME, "%s", file_name);
+    prctl(PR_SET_NAME, process_name);
+
+    /* SET ENVIROMENT*/
+    __set_env(menu_info, kb);
+
+    return 0;
+}
+
+_static_ void process_pool_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv)
+
+{
+    bundle *kb = NULL;
+    app_info_from_db *menu_info = NULL;
+
+    const char *pkg_name = NULL;
+    const char *app_path = NULL;
+
+    kb = bundle_decode(pkt->data, pkt->len);
+    if (!kb) {
+        _E("bundle decode error");
+        exit(-1);
+    }
+
+    pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
+    SECURE_LOGD("pkg name : %s", pkg_name);
+
+    menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
+    if (menu_info == NULL) {
+        _D("such pkg no found");
+        exit(-1);
+    }
+
+    app_path = _get_app_path(menu_info);
+
+    if (app_path == NULL) {
+        _E("app_path is NULL");
+        exit(-1);
+    }
+
+    if (app_path[0] != '/') {
+        _E("app_path is not absolute path");
+        exit(-1);
+    }
+
+    __modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info, pkt->cmd);
+    pkg_name = _get_pkgname(menu_info);
+    SECURE_LOGD("pkg name : %s", pkg_name);
+
+    __process_pool_prepare_exec(pkg_name, app_path, menu_info, kb);
+
+    if (out_app_path != NULL && out_argc != NULL && out_argv != NULL)
+    {
+        int i;
+
+        sprintf(out_app_path, "%s", app_path);
+
+        *out_argv = __create_argc_argv(kb, out_argc);
+        (*out_argv)[0] = out_app_path;
+
+        for (i = 0; i < *out_argc; i++)
+        {
+            _D("input argument %d : %s##", i, (*out_argv)[i]);
+        }
+    }
+    else
+    {
+        exit(-1);
+    }
+
+
+#if 0 // intentional
+    if (menu_info != NULL) {
+        _free_app_info_from_db(menu_info);
+    }
+
+    if (kb != NULL) {
+        bundle_free(kb);
+    }
+#endif
+}
+
+#endif // __PROCESS_POOL_LAUNCHPAD_UTIL_H_
\ No newline at end of file
index a988f74..bca51d2 100644 (file)
@@ -37,9 +37,6 @@ typedef struct handle_list_t {
 
 static inline void __preload_init(int argc, char **argv)
 {
-    char soname[MAX_LOCAL_BUFSZ] = { 0, };
-    FILE *preload_list;
-    int (*func)() = NULL;
     int i;
 
     g_argc = argc;
index a751121..a489dad 100644 (file)
@@ -1,3 +1,3 @@
-export WRT_PROCESS_POOL_DISABLE=ON
+#export WRT_PROCESS_POOL_DISABLE=ON
 #export WRT_WILL_SEND_REQUEST_LOG_ENABLE=ON
 #export WRT_LOAD_PLUGINS_LOG_ENABLE=ON