Register a new appid for dynamic box and its symbolic link to /usr/bin/WebProcess
authorYunchan Cho <yunchan.cho@samsung.com>
Mon, 26 Aug 2013 09:04:58 +0000 (18:04 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Tue, 10 Sep 2013 10:20:10 +0000 (10:20 +0000)
- 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
           2. wrt-installer adds 'root_path' attribute of <package> on application xml.
              - 'root_path' has application root directory (absolute path) as value,
                so that web-provider gets root dir of package using pkgmgr API.

Change-Id: Ic37d5172d9ee4434375858d5e441257ae8e7a736

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

index 80b37b0..49658c2 100644 (file)
@@ -153,6 +153,7 @@ void Manifest::serialize(xmlTextWriterPtr writer)
         writeAttribute(writer, "xmlns", "http://tizen.org/ns/packages");
         writeAttribute(writer, "package", this->package);
         writeAttribute(writer, "type", this->type);
+        writeAttribute(writer, "root_path", this->rootPath);
         writeAttribute(writer, "version", this->version);
         if (!this->installLocation.IsNull()) {
             writeAttribute(writer, "install-location", (*this->installLocation));
index 67ee3ce..d926c7e 100644 (file)
@@ -75,7 +75,7 @@ typedef StringWithLang LabelType, IconType, DescriptionType;
  * errors (related to usage of not allowed characters in given places).
  */
 typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
-typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType;
+typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType, RootPathType;
 typedef DPL::OptionalString InstallLocationType, CategoriesType;
 typedef DPL::String AppCategoryType;
 typedef DPL::OptionalString KeyType, ValueType;
@@ -554,6 +554,10 @@ class Manifest
     {
         this->version = x;
     }
+    void setRootPath(const RootPathType &x)
+    {
+        this->rootPath = x;
+    }
     void setStoreClientId(const NcnameType &x)
     {
         this->storeClientId= x;
@@ -575,6 +579,7 @@ class Manifest
     NcnameType package;
     PackageType type;
     NmtokenType version;
+    RootPathType rootPath;
     std::list<Account> account;
     PrivilegeType privileges;
     NcnameType storeClientId;
index 8308125..03fa597 100644 (file)
@@ -186,6 +186,23 @@ void TaskManifestFile::stepCreateExecFile()
                     << "[" <<  DPL::GetErrnoString(error) << "]");
     }
 #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) {
+                LogPedantic("Failed to make a symbolic name for a file "
+                        << "[" <<  DPL::GetErrnoString(errno) << "]");
+            }
+        }
+    }
+
     m_context.job->UpdateProgress(
             InstallerContext::INSTALL_CREATE_EXECFILE,
             "Widget execfile creation Finished");
@@ -320,7 +337,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("");
@@ -336,7 +353,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("");
@@ -347,7 +364,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
@@ -364,6 +381,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) {
+            LogDebug("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)
+    {
+        LogError("Adding UiApplication on xml is failed.");
+        isAdded = false;
+        return false;
+    }
+}
+
 void TaskManifestFile::stepBackupIconFiles()
 {
     LogDebug("Backup Icon Files");
@@ -888,6 +940,8 @@ void TaskManifestFile::generateWidgetDescription(Manifest & manifest,
 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
 {
     manifest.setPackage(m_context.widgetConfig.tzPkgid);
+    manifest.setRootPath(DPL::FromUTF8String(
+                m_context.locations->getPackageInstallationDir()));
 
     if (!!m_context.widgetConfig.version) {
         manifest.setVersion(*m_context.widgetConfig.version);
@@ -997,7 +1051,20 @@ void TaskManifestFile::setMetadata(UiApplication &uiApp)
 
 void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
 {
-    FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
+    ConfigParserData::LiveboxList& liveboxList =
+        m_context.widgetConfig.configInfo.m_livebox;
+
+    if (liveboxList.empty()) {
+        LogDebug("no livebox");
+        return;
+    }
+
+    if (!addBoxUiApplication(manifest)) {
+        LogDebug("error during adding UiApplication for d-box");
+        return;
+    }
+
+    FOREACH(it, liveboxList) {
         LogDebug("setLiveBoxInfo");
         LiveBoxInfo liveBox;
         DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
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();