#include <widget_install/job_widget_install.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
+#include <web_provider_livebox_info.h>
+#include <web_provider_plugin_info.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/log/log.h>
#include <dpl/file_input.h>
// for widget update.
AddStep(&TaskManifestFile::stepBackupIconFiles);
AddStep(&TaskManifestFile::stepCopyIconFiles);
+ AddStep(&TaskManifestFile::stepCopyLiveboxFiles);
+ AddStep(&TaskManifestFile::stepCreateExecFile);
AddStep(&TaskManifestFile::stepGenerateManifest);
AddStep(&TaskManifestFile::stepParseUpgradedManifest);
AddStep(&TaskManifestFile::stepUpdateFinalize);
AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
} else {
AddStep(&TaskManifestFile::stepCopyIconFiles);
+ AddStep(&TaskManifestFile::stepCopyLiveboxFiles);
AddStep(&TaskManifestFile::stepCreateExecFile);
AddStep(&TaskManifestFile::stepGenerateManifest);
AddStep(&TaskManifestFile::stepParseManifest);
std::string exec = m_context.locations->getExecFile();
std::string clientExeStr = GlobalConfig::GetWrtClientExec();
+#ifdef MULTIPROCESS_SERVICE_SUPPORT
//default widget
- LogInfo("link -s " << clientExeStr << " " << exec);
+ std::stringstream postfix;
+ postfix << AppControlPrefix::PROCESS_PREFIX << 0;
+ std::string controlExec = exec;
+ controlExec.append(postfix.str());
+
errno = 0;
- if (symlink(clientExeStr.c_str(), exec.c_str()) != 0)
+ if (symlink(clientExeStr.c_str(), controlExec.c_str()) != 0)
{
int error = errno;
if (error)
"Symbolic link creating is not done.");
}
-#ifdef MULTIPROCESS_SERVICE_SUPPORT
- //services
- std::size_t appcontrolCount =
- m_context.widgetConfig.configInfo.appControlList.size();
- for (std::size_t i = 0; i < appcontrolCount; ++i) {
+ // app-control widgets
+ unsigned int indexMax = 0;
+ FOREACH(it, m_context.widgetConfig.configInfo.appControlList) {
+ if (it->m_index > indexMax) {
+ indexMax = it->m_index;
+ }
+ }
+
+ for (std::size_t i = 1; i <= indexMax; ++i) {
std::stringstream postfix;
- postfix << "-__SERVICE_PROCESS__" << i;
- std::string serviceExec = exec;
- serviceExec.append(postfix.str());
+ postfix << AppControlPrefix::PROCESS_PREFIX << i;
+ std::string controlExec = exec;
+ controlExec.append(postfix.str());
errno = 0;
- if (symlink(clientExeStr.c_str(), serviceExec.c_str()) != 0)
- {
+ if (symlink(clientExeStr.c_str(), controlExec.c_str()) != 0) {
int error = errno;
- if (error)
+ if (error) {
LogPedantic("Failed to make a symbolic name for a file "
- << "[" << DPL::GetErrnoString(error) << "]");
+ << "[" << DPL::GetErrnoString(error) << "]");
+ }
ThrowMsg(Exceptions::FileOperationFailed,
- "Symbolic link creating is not done.");
+ "Symbolic link creating is not done.");
}
-
+ }
+#else
+ //default widget
+ LogInfo("link -s " << clientExeStr << " " << exec);
+ errno = 0;
+ if (symlink(clientExeStr.c_str(), exec.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");
"Widget iconfile copy Finished");
}
+void TaskManifestFile::stepCopyLiveboxFiles()
+{
+ LogDebug("Copy Livebox Files");
+
+ using namespace WrtDB;
+ ConfigParserData &data = m_context.widgetConfig.configInfo;
+ ConfigParserData::LiveboxList liveBoxList = data.m_livebox;
+
+ if (liveBoxList.size() <= 0) {
+ return;
+ }
+
+ std::ostringstream sourceFile;
+ std::ostringstream targetFile;
+
+ FOREACH (boxIt, liveBoxList) {
+ boxSizeType boxSizeList = (**boxIt).m_boxInfo.m_boxSize;
+ FOREACH (sizeIt, boxSizeList) {
+ std::string preview = DPL::ToUTF8String((*sizeIt).second);
+ if (preview.empty()) {
+ continue;
+ }
+ // copy preview image to shared directory
+ sourceFile << m_context.locations->getSourceDir() << "/";
+ sourceFile << preview;
+ targetFile << m_context.locations->getSharedDataDir() << "/";
+ targetFile << (**boxIt).m_liveboxId << ".";
+ targetFile << DPL::ToUTF8String((*sizeIt).first) << ".preview.png";
+
+ DPL::FileInput input(sourceFile.str());
+ DPL::FileOutput output(targetFile.str());
+ DPL::Copy(&input, &output);
+
+ // clear stream objects
+ sourceFile.str("");
+ targetFile.str("");
+ }
+ // check this livebox has icon element
+ std::string icon = DPL::ToUTF8String((**boxIt).m_icon);
+ if (icon.empty()) {
+ continue;
+ }
+ // copy icon to shared directory
+ sourceFile << m_context.locations->getSourceDir() << "/";
+ sourceFile << icon;
+ targetFile << m_context.locations->getSharedDataDir() << "/";
+ targetFile << (**boxIt).m_liveboxId << ".icon.png";
+
+ DPL::FileInput input(sourceFile.str());
+ DPL::FileOutput output(targetFile.str());
+ DPL::Copy(&input, &output);
+
+ // clear stream objects
+ sourceFile.str("");
+ targetFile.str("");
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_COPY_LIVEBOX_FILES,
+ "Livebox files copy Finished");
+}
+
void TaskManifestFile::stepBackupIconFiles()
{
LogDebug("Backup Icon Files");
- backup_dir << m_context.locations->getPackageInstallationDir();
- backup_dir << "/" << "backup" << "/";
+ backup_dir << m_context.locations->getBackupDir() << "/";
backupIconFiles();
void TaskManifestFile::stepParseUpgradedManifest()
{
- int code = pkgmgr_parser_parse_manifest_for_upgrade(
- DPL::ToUTF8String(manifest_file).c_str(), NULL);
+ if (m_context.widgetConfig.packagingType !=
+ PKG_TYPE_HYBRID_WEB_APP)
+ {
+ int code = pkgmgr_parser_parse_manifest_for_upgrade(
+ DPL::ToUTF8String(manifest_file).c_str(), NULL);
- if (code != 0) {
- LogError("Manifest parser error: " << code);
- ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
- }
+ if (code != 0) {
+ LogError("Manifest parser error: " << code);
+ ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
+ }
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_MANIFEST,
- "Widget Manifest Parsing Finished");
- LogDebug("Manifest parsed");
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_MANIFEST,
+ "Widget Manifest Parsing Finished");
+ LogDebug("Manifest parsed");
+ }
}
void TaskManifestFile::commitManifest()
LogDebug("Commiting manifest file : " << manifest_file);
std::ostringstream destFile;
- if (m_context.job->getInstallerStruct().m_installMode
- == InstallMode::INSTALL_MODE_PRELOAD)
- {
+ if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
destFile << "/usr/share/packages" << "/"; //TODO constant with path
} else {
destFile << "/opt/share/packages" << "/"; //TODO constant with path
Manifest manifest;
UiApplication uiApp;
+#ifdef MULTIPROCESS_SERVICE_SUPPORT
//default widget content
- setWidgetExecPath(uiApp);
+ std::stringstream postfix;
+ // index 0 is reserved
+ postfix << AppControlPrefix::PROCESS_PREFIX << 0;
+ setWidgetExecPath(uiApp, postfix.str());
setWidgetName(manifest, uiApp);
setWidgetIds(manifest, uiApp);
setWidgetIcons(uiApp);
setWidgetDescription(manifest);
setWidgetManifest(manifest);
setWidgetOtherInfo(uiApp);
-#ifndef MULTIPROCESS_SERVICE_SUPPORT
- setAppControlsInfo(uiApp);
-#endif
setAppCategory(uiApp);
+ setMetadata(uiApp);
setLiveBoxInfo(manifest);
setAccount(manifest);
setPrivilege(manifest);
-
manifest.addUiApplication(uiApp);
-#ifdef MULTIPROCESS_SERVICE_SUPPORT
- //services AppControl tag
+
+ //app-control content
ConfigParserData::AppControlInfoList appControlList =
m_context.widgetConfig.configInfo.appControlList;
- unsigned count = 0;
-
FOREACH(it, appControlList) {
- it->m_index = count;
UiApplication uiApp;
uiApp.setTaskmanage(true);
uiApp.setMultiple(ConfigParserData::AppControlInfo::Disposition::INLINE == it->m_disposition);
#endif
std::stringstream postfix;
- postfix << "-__SERVICE_PROCESS__" << count++;
-
+ postfix << AppControlPrefix::PROCESS_PREFIX << it->m_index;
setWidgetExecPath(uiApp, postfix.str());
setWidgetName(manifest, uiApp);
- setWidgetIds(manifest, uiApp, postfix.str());
+ setWidgetIds(manifest, uiApp);
setWidgetIcons(uiApp);
setAppControlInfo(uiApp, *it);
setAppCategory(uiApp);
- setAccount(manifest);
- setPrivilege(manifest);
-
+ setMetadata(uiApp);
manifest.addUiApplication(uiApp);
}
+#else
+ //default widget content
+ setWidgetExecPath(uiApp);
+ setWidgetName(manifest, uiApp);
+ setWidgetIds(manifest, uiApp);
+ setWidgetIcons(uiApp);
+ setWidgetDescription(manifest);
+ setWidgetManifest(manifest);
+ setWidgetOtherInfo(uiApp);
+ setAppControlsInfo(uiApp);
+ setAppCategory(uiApp);
+ setMetadata(uiApp);
+ setLiveBoxInfo(manifest);
+ setAccount(manifest);
+ setPrivilege(manifest);
+
+ manifest.addUiApplication(uiApp);
#endif
+
manifest.generate(path);
LogDebug("Manifest file serialized");
}
}
}
+void TaskManifestFile::setMetadata(UiApplication &uiApp)
+{
+ WrtDB::ConfigParserData::MetadataList metadataList =
+ m_context.widgetConfig.configInfo.metadataList;
+
+ if (metadataList.empty()) {
+ LogInfo("Web application doesn't contain metadata");
+ return;
+ }
+ FOREACH(it, metadataList) {
+ MetadataType metadataType(it->key, it->value);
+ uiApp.addMetadata(metadataType);
+ }
+}
+
void TaskManifestFile::stepAbortParseManifest()
{
LogError("[Parse Manifest] Abroting....");
liveBox.setLabel(ConfigInfo->m_label);
}
- DPL::String defaultLocale
- = DPL::FromUTF8String(
- m_context.locations->getPackageInstallationDir())
- + DPL::String(L"/res/wgt/");
+ DPL::String defaultLocale =
+ DPL::FromUTF8String(m_context.locations->getPackageInstallationDir()) +
+ DPL::String(L"/res/wgt/");
if (ConfigInfo->m_icon != L"") {
- liveBox.setIcon(defaultLocale + ConfigInfo->m_icon);
+ DPL::String icon =
+ DPL::FromUTF8String(m_context.locations->getSharedDataDir()) +
+ DPL::String(L"/") +
+ ConfigInfo->m_liveboxId + DPL::String(L".icon.png");
+ liveBox.setIcon(icon);
}
if (ConfigInfo->m_boxInfo.m_boxSrc.empty() ||
}
if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") {
- box.boxMouseEvent = ConfigInfo->m_boxInfo.m_boxMouseEvent;
+ std::string boxType;
+ if (ConfigInfo->m_type == L"") {
+ // in case of default livebox
+ boxType = web_provider_livebox_get_default_type();
+ } else {
+ boxType = DPL::ToUTF8String(ConfigInfo->m_type);
+ }
+
+ int box_scrollable =
+ web_provider_plugin_get_box_scrollable(boxType.c_str());
+
+ if (box_scrollable) {
+ box.boxMouseEvent = L"true";
+ } else {
+ box.boxMouseEvent = L"false";
+ }
} else {
box.boxMouseEvent = L"false";
}
if (ConfigInfo->m_boxInfo.m_boxTouchEffect == L"true") {
- box.boxTouchEffect = ConfigInfo->m_boxInfo.m_boxTouchEffect;
+ box.boxTouchEffect = L"true";
} else {
box.boxTouchEffect= L"false";
}
FOREACH(im, BoxSizeList) {
std::pair<DPL::String, DPL::String> boxSize = *im;
if (!boxSize.second.empty()) {
- boxSize.second = defaultLocale + boxSize.second;
+ boxSize.second =
+ DPL::FromUTF8String(m_context.locations->getSharedDataDir()) +
+ DPL::String(L"/") +
+ ConfigInfo->m_liveboxId + DPL::String(L".") +
+ boxSize.first + DPL::String(L".preview.png");
}
box.boxSize.push_back(boxSize);
}