Create symbolic link to /usr/bin/WebProcess for app with dynamic box
authorYunchan Cho <yunchan.cho@samsung.com>
Mon, 26 Aug 2013 09:04:58 +0000 (18:04 +0900)
committerSoo-Hyun Choi <sh9.choi@samsung.com>
Thu, 26 Sep 2013 02:49:28 +0000 (11:49 +0900)
- Tizen application is registered to app_info DB on installation time, hence
  this change needs to be done in wrt-installer

[Issue]    N/A
[Problem]  wrt-plugins (or external root daemon) cannot retrieve appid properly
           based on the pid of Box WebProcess.
[Cause]    app_manager API which gets appid from pid considers only
           registered executable path on app_info DB.
           (app_manager gets executable path from /proc/<pid>/cmdline
             matched to pid of WebProcess)
[Solution] WebProcess associated with the box needs to be registered to
           app_info DB on installation time.
           1. Register symbolic link (/usr/bin/WebProcess) per box
           2. Register the box's new appid to app_info DB on installation time

Change-Id: Ic6b59de89d6428b83f705da51c791806ac94e3ce

src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_manifest_file.h

index 6dc5fb3..cb7080d 100644 (file)
@@ -183,6 +183,21 @@ void TaskManifestFile::stepCreateExecFile()
             _E("Failed to make a symbolic name for a file [%s]", DPL::GetErrnoString(error).c_str());
     }
 #endif
+    // creation of box symlink
+    ConfigParserData::LiveboxList& liveboxList =
+        m_context.widgetConfig.configInfo.m_livebox;
+    if (!liveboxList.empty()) {
+        std::string boxExec = "/usr/bin/WebProcess";
+        std::string boxSymlink = m_context.locations->getExecFile();
+        boxSymlink += ".d-box";
+
+        if (symlink(boxExec.c_str(), boxSymlink.c_str()) != 0) {
+            if (errno) {
+                _E("Failed to make a symbolic name for a file [%s]", DPL::GetErrnoString(errno).c_str());
+            }
+        }
+    }
+
     m_context.job->UpdateProgress(
             InstallerContext::INSTALL_CREATE_EXECFILE,
             "Widget execfile creation Finished");
@@ -314,7 +329,7 @@ void TaskManifestFile::stepCopyLiveboxFiles()
             targetFile << (**boxIt).m_liveboxId << ".";
             targetFile << DPL::ToUTF8String((*sizeIt).m_size) << "." << DEFAULT_PREVIEW_NAME;
 
-            DynamicBoxFileCopy(sourceFile.str(), targetFile.str());
+            copyDynamicBoxFile(sourceFile.str(), targetFile.str());
 
             // clear stream objects
             sourceFile.str("");
@@ -330,7 +345,7 @@ void TaskManifestFile::stepCopyLiveboxFiles()
         targetFile << m_context.locations->getSharedDataDir() << "/";
         targetFile << (**boxIt).m_liveboxId << "." << DEFAULT_ICON_NAME;
 
-        DynamicBoxFileCopy(sourceFile.str(), targetFile.str());
+        copyDynamicBoxFile(sourceFile.str(), targetFile.str());
 
         // clear stream objects
         sourceFile.str("");
@@ -341,7 +356,7 @@ void TaskManifestFile::stepCopyLiveboxFiles()
         "Livebox files copy Finished");
 }
 
-void TaskManifestFile::DynamicBoxFileCopy(const std::string& sourceFile,
+void TaskManifestFile::copyDynamicBoxFile(const std::string& sourceFile,
                                           const std::string& targetFile)
 {
     Try
@@ -357,6 +372,41 @@ void TaskManifestFile::DynamicBoxFileCopy(const std::string& sourceFile,
     }
 }
 
+bool TaskManifestFile::addBoxUiApplication(Manifest& manifest)
+{
+    UiApplication uiApp;
+    std::string postfix = ".d-box";
+    static bool isAdded = false;
+
+    Try
+    {
+        if (isAdded) {
+            _D("UiApplication for d-box is already added");
+            return false;
+        }
+        uiApp.setNodisplay(true);
+        uiApp.setTaskmanage(false);
+        uiApp.setMultiple(false);
+        setWidgetName(manifest, uiApp);
+        setWidgetIcons(uiApp);
+
+        // appid for box is like [webapp id].d-box
+        setWidgetIds(manifest, uiApp, postfix);
+        // executable path for box is like [app path]/bin/[webapp id].d-box
+        setWidgetExecPath(uiApp, postfix);
+        manifest.addUiApplication(uiApp);
+        isAdded = true;
+
+        return true;
+    }
+    Catch(DPL::Exception)
+    {
+        _E("Adding UiApplication on xml is failed.");
+        isAdded = false;
+        return false;
+    }
+}
+
 void TaskManifestFile::stepBackupIconFiles()
 {
     _D("Backup Icon Files");
@@ -983,8 +1033,21 @@ void TaskManifestFile::setMetadata(UiApplication &uiApp)
 
 void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
 {
-    FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
-        _D("setLiveBoxInfo");
+    ConfigParserData::LiveboxList& liveboxList =
+        m_context.widgetConfig.configInfo.m_livebox;
+
+    if (liveboxList.empty()) {
+        _D("no livebox");
+        return;
+    }
+
+    if (!addBoxUiApplication(manifest)) {
+        _D("error during adding UiApplication for d-box");
+        return;
+    }
+
+    FOREACH(it, liveboxList) {
+        LogDebug("setLiveBoxInfo");
         LiveBoxInfo liveBox;
         DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
         DPL::String appid = m_context.widgetConfig.tzAppid;
index 98c3d23..dee925d 100644 (file)
@@ -120,8 +120,9 @@ class TaskManifestFile :
                             const DPL::OptionalString& tag,
                             const DPL::String& language, const std::string &extension,
                             bool & defaultIconSaved);
-    void DynamicBoxFileCopy(const std::string& sourceFile,
+    void copyDynamicBoxFile(const std::string& sourceFile,
                             const std::string& targetFile);
+    bool addBoxUiApplication(Manifest& manifest);
 
     //for widget update
     void backupIconFiles();