From: Lukasz Marek Date: Mon, 11 Mar 2013 13:17:20 +0000 (+0100) Subject: Service runs as separate process X-Git-Tag: accepted/tizen_2.1/20130425.023916~8^2~10 X-Git-Url: http://review.tizen.org/git/?p=framework%2Fweb%2Fwrt-installer.git;a=commitdiff_plain;h=ceca4e287d715bf26e923e81b2d45a3f056927af Service runs as separate process [Issue#] N/A [Problem] N/A [Cause] Service with window disposition must be visible in task manager [Solution] Services are defined as separate applications. [SCMRequest] N/A [Verification] Install and run any widget Change-Id: Idb676aa3009137abb140e0d0a6aee2041056498a --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a23ce2..4a9698b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++0x -g --coverage") OPTION(DPL_LOG "DPL logs status" ON) OPTION(WITH_TESTS "Build tests" OFF) +OPTION(MULTIPROCESS_SERVICE_SUPPORT "Process per service" OFF) IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling") MESSAGE(STATUS "Logging enabled for DPL") ADD_DEFINITIONS("-DDPL_LOGS_ENABLED") @@ -61,6 +62,9 @@ ELSE(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling") MESSAGE(STATUS "Logging disabled for DPL") ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling") MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS}) +IF(MULTIPROCESS_SERVICE_SUPPORT) + ADD_DEFINITIONS("-DMULTIPROCESS_SERVICE_SUPPORT") +ENDIF(MULTIPROCESS_SERVICE_SUPPORT) # If supported for the target machine, emit position-independent code,suitable # for dynamic linking and avoiding any limit on the size of the global offset diff --git a/src/jobs/widget_install/manifest.h b/src/jobs/widget_install/manifest.h index e6f7827..d30ef15 100644 --- a/src/jobs/widget_install/manifest.h +++ b/src/jobs/widget_install/manifest.h @@ -53,6 +53,11 @@ class StringWithLang { return !this->lang.empty(); } + int operator==(const StringWithLang &other) + { + return (DPL::ToUTF8String(other.string) == DPL::ToUTF8String(string)) && + (DPL::ToUTF8String(other.lang) == DPL::ToUTF8String(lang)); + } private: DPL::String string; @@ -449,7 +454,14 @@ class Manifest void addLabel(const LabelType &x) { +#ifdef MULTIPROCESS_SERVICE_SUPPORT + auto pos = std::find(label.begin(), label.end(), x); + if (pos == label.end()) { + this->label.push_back(x); + } +#else this->label.push_back(x); +#endif } void addIcon(const IconType &x) { diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp index a5124a0..f6bc038 100644 --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -133,18 +133,43 @@ void TaskManifestFile::stepCreateExecFile() std::string exec = m_context.locations->getExecFile(); std::string clientExeStr = GlobalConfig::GetWrtClientExec(); + //default widget LogInfo("link -s " << clientExeStr << " " << exec); - errno = 0; - if (symlink(clientExeStr.c_str(), exec.c_str()) != 0) + if (symlink(clientExeStr.c_str(), exec.c_str()) != 0) { int error = errno; - if(error) + if (error) LogPedantic("Failed to make a symbolic name for a file " << "[" << DPL::GetErrnoString(error) << "]"); ThrowMsg(Exceptions::FileOperationFailed, "Symbolic link creating is not done."); } + +#ifdef MULTIPROCESS_SERVICE_SUPPORT + //services + std::size_t serviceCount = + m_context.widgetConfig.configInfo.appControlList.size(); + serviceCount += m_context.widgetConfig.configInfo.appServiceList.size(); + for (std::size_t i = 0; i < serviceCount; ++i) { + std::stringstream postfix; + postfix << "-__SERVICE_PROCESS__" << i; + std::string serviceExec = exec; + serviceExec.append(postfix.str()); + errno = 0; + if (symlink(clientExeStr.c_str(), serviceExec.c_str()) != 0) + { + int error = errno; + if (error) + LogPedantic("Failed to make a symbolic name for a file " + << "[" << DPL::GetErrnoString(error) << "]"); + ThrowMsg(Exceptions::FileOperationFailed, + "Symbolic link creating is not done."); + } + + } +#endif + m_context.job->UpdateProgress( InstallerContext::INSTALL_CREATE_EXECFILE, "Widget execfile creation Finished"); @@ -572,29 +597,93 @@ void TaskManifestFile::writeManifest(const DPL::String & path) Manifest manifest; UiApplication uiApp; + //default widget content setWidgetExecPath(uiApp); setWidgetName(manifest, uiApp); + setWidgetIds(manifest, uiApp); setWidgetIcons(uiApp); setWidgetManifest(manifest); setWidgetOtherInfo(uiApp); - setAppServiceInfo(uiApp); - setAppControlInfo(uiApp); +#ifndef MULTIPROCESS_SERVICE_SUPPORT + setAppServicesInfo(uiApp); + setAppControlsInfo(uiApp); +#endif setAppCategory(uiApp); setLiveBoxInfo(manifest); setAccount(manifest); setPrivilege(manifest); manifest.addUiApplication(uiApp); +#ifdef MULTIPROCESS_SERVICE_SUPPORT + //services AppControl tag + ConfigParserData::AppControlInfoList appControlList = + m_context.widgetConfig.configInfo.appControlList; + unsigned count = 0; + + FOREACH(it, appControlList) { + it->m_index = count; + UiApplication uiApp; + + uiApp.setTaskmanage(true); + uiApp.setNodisplay(true); + + std::stringstream postfix; + postfix << "-__SERVICE_PROCESS__" << count++; + + setWidgetExecPath(uiApp, postfix.str()); + setWidgetName(manifest, uiApp); + setWidgetIds(manifest, uiApp, postfix.str()); + setWidgetIcons(uiApp); + setAppControlInfo(uiApp, *it); + setAppCategory(uiApp); + setAccount(manifest); + setPrivilege(manifest); + + manifest.addUiApplication(uiApp); + } + //TODO: AppService tag will be removed + //services AppService tag + WrtDB::ConfigParserData::ServiceInfoList appServiceList = + m_context.widgetConfig.configInfo.appServiceList; + FOREACH(it, appServiceList) { + it->m_index = count; + UiApplication uiApp; + + uiApp.setTaskmanage(true); + uiApp.setNodisplay(true); + + std::stringstream postfix; + postfix << "-__SERVICE_PROCESS__" << count++; + + setWidgetExecPath(uiApp, postfix.str()); + setWidgetName(manifest, uiApp); + setWidgetIds(manifest, uiApp, postfix.str()); + setWidgetIcons(uiApp); + setAppServiceInfo(uiApp, *it); + setAppCategory(uiApp); + setAccount(manifest); + setPrivilege(manifest); + + manifest.addUiApplication(uiApp); + } +#endif manifest.generate(path); LogDebug("Manifest file serialized"); } -void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp) +void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp, + const std::string &postfix) { - uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile())); + std::string exec = m_context.locations->getExecFile(); + if (!postfix.empty()) { + exec.append(postfix); + } + LogDebug("exec = " << exec); + uiApp.setExec(DPL::FromASCIIString(exec)); } -void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp) +void TaskManifestFile::setWidgetName(Manifest & manifest, + UiApplication & uiApp) { bool defaultNameSaved = false; @@ -627,8 +716,17 @@ void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp) name, defaultNameSaved); } +} + +void TaskManifestFile::setWidgetIds(Manifest & manifest, + UiApplication & uiApp, + const std::string &postfix) +{ //appid TizenAppId appid = m_context.widgetConfig.tzAppid; + if (!postfix.empty()) { + appid = DPL::FromUTF8String(DPL::ToUTF8String(appid).append(postfix)); + } uiApp.setAppid(appid); //extraid @@ -781,7 +879,7 @@ void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp) //that were in desktop file } -void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp) +void TaskManifestFile::setAppServicesInfo(UiApplication & uiApp) { WrtDB::ConfigParserData::ServiceInfoList appServiceList = m_context.widgetConfig.configInfo.appServiceList; @@ -793,21 +891,11 @@ void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp) // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; FOREACH(it, appServiceList) { - AppControl appControl; - if (!it->m_operation.empty()) { - appControl.addOperation(it->m_operation); //TODO: encapsulation? - } - if (!it->m_scheme.empty()) { - appControl.addUri(it->m_scheme); - } - if (!it->m_mime.empty()) { - appControl.addMime(it->m_mime); - } - uiApp.addAppControl(appControl); - } -} + setAppServiceInfo(uiApp, *it); + } + } -void TaskManifestFile::setAppControlInfo(UiApplication & uiApp) +void TaskManifestFile::setAppControlsInfo(UiApplication & uiApp) { WrtDB::ConfigParserData::AppControlInfoList appControlList = m_context.widgetConfig.configInfo.appControlList; @@ -817,24 +905,47 @@ void TaskManifestFile::setAppControlInfo(UiApplication & uiApp) return; } - // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; + // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; FOREACH(it, appControlList) { - AppControl appControl; - if (!it->m_operation.empty()) { - appControl.addOperation(it->m_operation); //TODO: encapsulation? - } - if (!it->m_uriList.empty()) { - FOREACH(uri, it->m_uriList) { - appControl.addUri(*uri); - } + setAppControlInfo(uiApp, *it); + } +} + +void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp, + const ConfigParserData::ServiceInfo & service) +{ + AppControl appControl; + if (!service.m_operation.empty()) { + appControl.addOperation(service.m_operation); //TODO: encapsulation? + } + if (!service.m_scheme.empty()) { + appControl.addUri(service.m_scheme); + } + if (!service.m_mime.empty()) { + appControl.addMime(service.m_mime); + } + uiApp.addAppControl(appControl); +} + +void TaskManifestFile::setAppControlInfo(UiApplication & uiApp, + const WrtDB::ConfigParserData::AppControlInfo & service) +{ + // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; + AppControl appControl; + if (!service.m_operation.empty()) { + appControl.addOperation(service.m_operation); //TODO: encapsulation? + } + if (!service.m_uriList.empty()) { + FOREACH(uri, service.m_uriList) { + appControl.addUri(*uri); } - if (!it->m_mimeList.empty()) { - FOREACH(mime, it->m_mimeList) { - appControl.addMime(*mime); - } + } + if (!service.m_mimeList.empty()) { + FOREACH(mime, service.m_mimeList) { + appControl.addMime(*mime); } - uiApp.addAppControl(appControl); } + uiApp.addAppControl(appControl); } void TaskManifestFile::setAppCategory(UiApplication &uiApp) diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h index 0cdbe61..36a1c92 100644 --- a/src/jobs/widget_install/task_manifest_file.h +++ b/src/jobs/widget_install/task_manifest_file.h @@ -89,14 +89,23 @@ class TaskManifestFile : void writeManifest(const DPL::String & path); void commitManifest(); - void setWidgetExecPath(UiApplication & uiApp); - void setWidgetName(Manifest & manifest, UiApplication & uiApp); + void setWidgetExecPath(UiApplication & uiApp, + const std::string &postfix = std::string()); + void setWidgetName(Manifest & manifest, + UiApplication & uiApp); + void setWidgetIds(Manifest & manifest, + UiApplication & uiApp, + const std::string &postfix = std::string()); void setWidgetIcons(UiApplication & uiApp); void setWidgetManifest(Manifest & manifest); void setWidgetOtherInfo(UiApplication & uiApp); /* please use AppControl. this function will be removed. */ - void setAppServiceInfo(UiApplication & uiApp); - void setAppControlInfo(UiApplication & uiApp); + void setAppServicesInfo(UiApplication & uiApp); + void setAppControlsInfo(UiApplication & uiApp); + void setAppServiceInfo(UiApplication & uiApp, + const WrtDB::ConfigParserData::ServiceInfo & service); + void setAppControlInfo(UiApplication & uiApp, + const WrtDB::ConfigParserData::AppControlInfo & service); void setAppCategory(UiApplication & uiApp); void setLiveBoxInfo(Manifest& manifest); void setAccount(Manifest& uiApp);