ADD_DEFINITIONS("-Wextra") # Generate even more extra warnings
ADD_DEFINITIONS("-Wno-variadic-macros") # Inhibit variadic macros warnings (needed for ORM)
ADD_DEFINITIONS("-Wno-deprecated") # No warnings about deprecated features
-ADD_DEFINITIONS("-std=c++0x") # No warnings about deprecated features
+ADD_DEFINITIONS("-std=c++0x") # accept C++11x standard
#ADD_DEFINITIONS("-DWRT_SMACK_ENABLED")
############################# Targets names ###################################
+wrt-installer (0.0.54) unstable; urgency=low
+
+ * Parsing XML namespace from config.xml bug fix.
+ * code clean up
+ * TaskDbUpdate splitted into TaskDbUpdate and TaskFileManipulation
+ * Widget paths refactor
+
+ * Git : framework/web/wrt-installer
+ * Tag : wrt-installer_0.0.54
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com> Fri, 31 Aug 2012 20:38:33 +0900
+
wrt-installer (0.0.53) unstable; urgency=low
* [Installer] Add encrypt task
-#sbs-git:slp/pkgs/w/wrt-installer wrt-installer 0.0.53
+#sbs-git:slp/pkgs/w/wrt-installer wrt-installer 0.0.54
Name: wrt-installer
Summary: Installer for tizen Webruntime
-Version: 0.0.53
+Version: 0.0.54
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
${INSTALLER_CONFIG_PARSER}/ignoring_parser.cpp
${INSTALLER_CONFIG_PARSER}/deny_all_parser.cpp
${INSTALLER_CONFIG_PARSER}/libiriwrapper.cpp
- ${INSTALLER_CONFIG_PARSER}/WidgetConfigurationManager.cpp
${INSTALLER_JOBS}/job.cpp
${INSTALLER_JOBS}/plugin_install/job_plugin_install.cpp
${INSTALLER_JOBS}/plugin_install/plugin_install_task.cpp
${INSTALLER_JOBS}/widget_install/task_unzip.cpp
${INSTALLER_JOBS}/widget_install/task_widget_config.cpp
${INSTALLER_JOBS}/widget_install/task_db_update.cpp
+ ${INSTALLER_JOBS}/widget_install/task_file_manipulation.cpp
${INSTALLER_JOBS}/widget_install/task_smack.cpp
${INSTALLER_JOBS}/widget_install/task_ace_check.cpp
${INSTALLER_JOBS}/widget_install/task_manifest_file.cpp
${INSTALLER_SRC_DIR}/misc/wac_widget_id.cpp
${INSTALLER_SRC_DIR}/misc/feature_logic.cpp
${INSTALLER_SRC_DIR}/misc/libxml_utils.cpp
+ ${INSTALLER_SRC_DIR}/misc/widget_location.cpp
${INSTALLER_SRC_DIR}/pkg-manager/pkgmgr_signal.cpp
)
struct XmlAttribute
{
+ DPL::String prefix;
DPL::String name;
DPL::String value;
DPL::String ns;
XmlAttribute attribute;
attribute.ns = GetAttributeNamespace();
+ attribute.prefix = GetNamePrefix();
attribute.name = GetNameWithoutNamespace();
attribute.value = GetValue();
attribute.lang = GetLanguageTag();
LogDebug("Attribute name: " << attribute.name <<
", value: " << attribute.value <<
+ ", prefix: " << attribute.prefix <<
", namespace: " << attribute.ns <<
", lang: " << attribute.lang);
parser->Accept(attribute);
DPL::String ret_value;
const xmlChar* value = xmlTextReaderConstValue(m_reader);
if (value) {
- ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+ ret_value =
+ DPL::FromUTF8String(reinterpret_cast<const char*>(value));
}
return ret_value;
DPL::String ret_value;
const xmlChar* value = xmlTextReaderGetAttributeNo(m_reader, pos);
if (value) {
- ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+ ret_value =
+ DPL::FromUTF8String(reinterpret_cast<const char*>(value));
}
xmlFree(const_cast<xmlChar*>(value));
DPL::String ret_value;
const xmlChar* value = xmlTextReaderLookupNamespace(m_reader, NULL);
if (value) {
- ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+ ret_value =
+ DPL::FromUTF8String(reinterpret_cast<const char*>(value));
}
xmlFree(const_cast<xmlChar*>(value));
DPL::String ret_value;
const xmlChar* value = xmlTextReaderConstName(m_reader);
if (value) {
- ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+ ret_value =
+ DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+ }
+
+ return ret_value;
+ }
+
+ DPL::String GetNamePrefix() const
+ {
+ DPL::String ret_value;
+ const xmlChar* value = xmlTextReaderPrefix(m_reader);
+ if (value) {
+ ret_value =
+ DPL::FromUTF8String(reinterpret_cast<const char*>(value));
}
return ret_value;
DPL::String ret_value;
const xmlChar* value = xmlTextReaderLocalName(m_reader);
if (value) {
- ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+ ret_value =
+ DPL::FromUTF8String(reinterpret_cast<const char*>(value));
}
return ret_value;
const xmlChar* value = xmlTextReaderConstNamespaceUri(m_reader);
if (value) {
- ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+ ret_value =
+ DPL::FromUTF8String(reinterpret_cast<const char*>(value));
}
return ret_value;
DPL::String ret_value;
const xmlChar* value = xmlTextReaderConstXmlLang(m_reader);
if (value) {
- ret_value = DPL::FromUTF8String(reinterpret_cast<const char*>(value));
+ ret_value =
+ DPL::FromUTF8String(reinterpret_cast<const char*>(value));
}
return ret_value;
}
//Any other value consider as a namespace definition
- } else if (attribute.name == L"xmlns" ||
- attribute.ns == m_nameSpaces[L"xmlns"]) {
+ } else if (attribute.name == L"xmlns" || attribute.prefix == L"xmlns") {
LogInfo("Namespace domain: " << attribute.name);
LogInfo("Namespace value: " << attribute.value);
m_nameSpaces[attribute.name] = attribute.value;
m_paused = false;
// Trigger next steps
- CONTROLLER_POST_EVENT(InstallerController,
+ CONTROLLER_POST_EVENT(Logic::InstallerController,
InstallerControllerEvents::NextStepEvent(this));
}
#include <dpl/assert.h>
#include <dpl/sstream.h>
#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <dpl/utils/file_utils.h>
#include "root_parser.h"
#include "widget_parser.h"
#include "parser_runner.h"
#include <widget_install/task_certify.h>
#include <widget_install/task_widget_config.h>
#include <widget_install/task_db_update.h>
+#include <widget_install/task_file_manipulation.h>
#include <widget_install/task_ace_check.h>
#include <widget_install/task_smack.h>
#include <widget_install/task_manifest_file.h>
m_exceptionCaught(Exceptions::Success)
{
// Check installation type (config.xml or widget.wgt)
- m_installerContext.browserRequest = hasExtension(widgetPath, XML_EXTENSION);
+ bool browserRequest = hasExtension(widgetPath, XML_EXTENSION);
- LogInfo("Hosted app installation: " << m_installerContext.browserRequest);
+ LogInfo("Hosted app installation: " << browserRequest);
struct timeval tv;
gettimeofday(&tv, NULL);
m_installerContext.widgetHandle = handle;
m_installerContext.m_quiet = m_jobStruct.m_quiet;
- m_installerContext.widgetConfig.pType = checkPackageType(widgetPath);
+ if(!browserRequest)
+ {
+ m_installerContext.widgetConfig.pType = checkPackageType(widgetPath);
+ }
+ else
+ {
+ m_installerContext.widgetConfig.pType = WrtDB::PKG_TYPE_TIZEN_WEBAPP;
+ }
+ LogDebug("widgetPath:" << widgetPath);
- ConfigParserData configData = getWidgetDataFromXML(widgetPath,
- m_installerContext.browserRequest,
+ ConfigParserData configData = getWidgetDataFromXML(widgetPath, browserRequest,
m_installerContext.widgetConfig.pType);
WidgetUpdateInfo update = detectWidgetUpdate(configData);
+
bool needEncryption = detectResourceEncryption(configData);
+
// Configure installation
- ConfigureResult result = ConfigureInstallation(widgetPath,
- m_installerContext.browserRequest, update);
+ ConfigureResult result = ConfigureInstallation(widgetPath, update);
if (!setTizenId(configData)) {
result = ConfigureResult::Failed;
} else {
LogInfo("WidgetHandle: " << m_installerContext.widgetHandle);
LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
+ configureWidgetLocation(widgetPath, browserRequest);
+
// send start signal of pkgmgr
PkgmgrSignalSingleton::Instance().setPkgname(
DPL::ToUTF8String(
PKGMGR_START_KEY,
PKGMGR_START_INSTALL);
}
-
if (result == ConfigureResult::Ok) {
LogInfo("Configure installation succeeded");
AddTask(new TaskRecovery(m_installerContext));
// Create installation tasks
- if (!m_installerContext.browserRequest) {
+ if (!m_installerContext.locations->browserRequest()) {
AddTask(new TaskUnzip(m_installerContext));
}
AddTask(new TaskWidgetConfig(m_installerContext));
+ if (m_installerContext.locations->browserRequest()) {
+ AddTask(new TaskPrepareFiles(m_installerContext));
+ }
AddTask(new TaskCertify(m_installerContext));
if (needEncryption) {
AddTask(new TaskEncryptResource(m_installerContext));
}
AddTask(new TaskDbUpdate(m_installerContext));
+ AddTask(new TaskFileManipulation(m_installerContext));
// TODO: Update progress information for this task
AddTask(new TaskPrivateStorage(m_installerContext));
LogInfo("Configure installation updated");
LogInfo("Widget Update");
- if (!m_installerContext.browserRequest) {
+ if (!m_installerContext.locations->browserRequest()) {
AddTask(new TaskUnzip(m_installerContext));
}
AddTask(new TaskWidgetConfig(m_installerContext));
+ if (m_installerContext.locations->browserRequest()) {
+ AddTask(new TaskPrepareFiles(m_installerContext));
+ }
AddTask(new TaskCertify(m_installerContext));
AddTask(new TaskUpdateFiles(m_installerContext));
return m_installerContext.widgetHandle;
}
+void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath, bool browserRequest)
+{
+ Try
+ {
+ m_installerContext.locations = WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
+ widgetPath, browserRequest, m_installerContext.widgetConfig.pType);
+ }
+ Catch(FileUtils::CreateDirectoryException)
+ {
+ LogError("Failed to create temporary path for widget");
+ ReThrowMsg(FileUtils::CreateDirectoryException, "Failed to create temporary path for widget");
+ }
+
+ LogInfo("widgetSource " << widgetPath);
+}
+
JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
const std::string &widgetSource,
- bool fromBrowser,
const WidgetUpdateInfo &update)
{
LogInfo(
LogInfo("Whether widget policy allow proceed: " << canProceed);
// Init installer context
- m_installerContext.widgetSource = widgetSource;
- m_installerContext.tempWidgetPath = std::string();
-
- // setup config xml path
- if (fromBrowser) {
- LogInfo("widgetSource " << widgetSource);
- size_t slash = widgetSource.find_last_of("\\/");
- if (std::string::npos != slash) {
- m_installerContext.tempWidgetPath = widgetSource.substr(0, slash+1);
- } else {
- m_installerContext.tempWidgetPath = ".";
- }
- }
-
m_installerContext.installStep = InstallerContext::INSTALL_START;
m_installerContext.job = this;
m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
InstallerContext m_installerContext;
- //TODO move it to base class of all jobs
+ //TODO move it to base class of all jobs -> make it base template class??
Exceptions::Type m_exceptionCaught;
std::string m_exceptionMessage;
WidgetUpdateInfo m_widgetUpdateInfo;
};
ConfigureResult ConfigureInstallation(const std::string &widgetSource,
- bool fromBrowser,
const WidgetUpdateInfo &update);
static WrtDB::ConfigParserData getWidgetDataFromXML(
const std::string &widgetSource,
const OptionalWidgetVersion &incomingVersion) const;
bool setTizenId(const WrtDB::ConfigParserData &configInfo);
void displayWidgetInfo();
+ void configureWidgetLocation(const std::string & widgetPath, bool browserRequest);
WrtDB::PackagingType checkPackageType(
const std::string &widgetSorce);
}
}
-//TODO shouldn't XML file creation happen here? If no, this method is not needed
void Manifest::generate(DPL::String filename)
{
xmlTextWriterPtr writer;
void TaskAceCheck::StepProcessAceResponse()
{
- if (m_context.browserRequest) {
+ if (m_context.locations->browserRequest()) {
return;
}
{
LogInfo("enter");
- std::string widgetPath = m_contextData.tempWidgetRoot + "/";
+ std::string widgetPath = m_contextData.locations->getTemporaryRootDir() + "/";
SignatureFileInfoSet signatureFiles;
SignatureFinder signatureFinder(widgetPath);
namespace Jobs {
namespace WidgetInstall {
+//TODO make directory like jobs common?
+
void removeTemporaryDir(const std::string& path);
std::string createTempPath();
* @version 1.0
* @brief Implementation file for installer task database updating
*/
-#include <time.h>
-#include <sys/stat.h>
+//#include <time.h>
#include <widget_install/task_db_update.h>
#include <widget_install/job_widget_install.h>
#include <widget_install/widget_install_errors.h>
#include <dpl/assert.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <string>
-//#include <widget_controller.h>
#include <Ecore_File.h>
#include <sstream>
m_context(context)
{
AddStep(&TaskDbUpdate::StepDbUpdate);
- AddStep(&TaskDbUpdate::StepCreateDirs);
- AddStep(&TaskDbUpdate::StepRenamePath);
-
AddAbortStep(&TaskDbUpdate::StepAbortDBUpdate);
- AddAbortStep(&TaskDbUpdate::StepAbortRenamePath);
-}
-
-void TaskDbUpdate::StepCreateDirs()
-{
- std::ostringstream widgetPath;
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- widgetPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- widgetPath << pkgname << "/";
-
- std::string widgetBinPath = widgetPath.str();
- std::string widgetSrcPath = widgetPath.str();
-
- _WrtMakeDir(widgetPath.str().c_str(), 0755, WRT_FILEUTILS_RECUR);
-
- // If pakcage type is widget with osp service, we don't need to make bin
- // and src directory
- if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
- LogDebug("Doesn't need to create resource directory");
- } else {
- LogDebug("Create resource directory");
- widgetBinPath += GlobalConfig::GetUserWidgetExecPath();
- _WrtMakeDir(widgetBinPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
-
- widgetSrcPath += GlobalConfig::GetWidgetSrcPath();
- _WrtMakeDir(widgetSrcPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_DIR_CREATE,
- "Widget Directory Created");
}
void TaskDbUpdate::StepDbUpdate()
"Widget DB UPDATE Finished");
}
-void TaskDbUpdate::StepRenamePath()
-{
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
- if (pkgname.IsNull()) {
- ThrowMsg(Exceptions::InternalError, "No Package name exists.");
- }
-
- if (!_WrtUtilRemoveDir(m_context.installPath.c_str())) {
- _WrtUtilChangeDir(GlobalConfig::GetUserInstalledWidgetPath());
- ThrowMsg(Exceptions::RemovingFolderFailure,
- "Error occurs during removing existing folder");
- }
-
- if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
- LogDebug("Copy file from temp directory to " <<
- m_context.installPath);
-
- if (rename(m_context.tempWidgetPath.c_str(),
- m_context.installPath.c_str()) < 0) {
- ThrowMsg(Exceptions::UnknownError,
- "Error occurs during renaming widget folder");
- }
- } else {
- LogDebug("Copy file from temp directory to " <<
- m_context.installPath);
-
- if (!m_context.browserRequest) {
- if (rename(m_context.tempWidgetRoot.c_str(), m_context.installPath.c_str()) < 0) {
- ThrowMsg(Exceptions::UnknownError,
- "Error occurs during renaming widget folder");
- }
- }
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_RENAME_PATH,
- "Widget Rename path Finished");
-}
-
void TaskDbUpdate::StepAbortDBUpdate()
{
LogWarning("[DB Update Task] Aborting... (DB Clean)");
}
}
-void TaskDbUpdate::StepAbortRenamePath()
-{
- LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
- Assert(!!m_context.widgetHandle);
- std::ostringstream widgetPath;
- widgetPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- widgetPath << *m_context.widgetConfig.pkgname;
-
- struct stat fileInfo;
- if (stat(widgetPath.str().c_str(), &fileInfo) != 0) {
- LogError("Failed to get widget file path : " <<widgetPath.str());
- return;
- }
-
- if (rename(widgetPath.str().c_str(),
- m_context.tempWidgetPath.c_str()) < 0) {
- LogError("Failed to rename");
- //Ignoring failures in Abort
- }
- LogDebug("Rename widget path sucessful!");
-}
} //namespace WidgetInstall
} //namespace Jobs
private:
InstallerContext& m_context;
- void StepCreateDirs();
void StepDbUpdate();
- void StepRenamePath();
void StepAbortDBUpdate();
- void StepAbortRenamePath();
public:
TaskDbUpdate(InstallerContext& context);
m_resEnc->CreateEncryptionKey(DPL::ToUTF8String(*m_context.
widgetConfig.pkgname));
- if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
- tempInstalledPath = m_context.tempWidgetPath;
- } else {
- tempInstalledPath = m_context.tempWidgetRoot;
- }
-
- EncryptDirectory(tempInstalledPath);
+ EncryptDirectory(m_context.locations->getTemporaryRootDir());
}
void TaskEncryptResource::EncryptDirectory(std::string path)
}
std::string realPath = fileName;
- realPath.replace(0, tempInstalledPath.length(),
- m_context.installPath);
+ realPath.replace(0, m_context.locations->getTemporaryRootDir().length(),
+ m_context.locations->getPackageInstallationDir());
WrtDB::EncryptedFileInfo info;
info.fileName = DPL::FromUTF8String(realPath);
--- /dev/null
+/*
+ * Copyright (c) 2011 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 task_db_update.cpp
+ * @author Lukasz Wrzosek(l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer task database updating
+ */
+#include <sys/stat.h>
+#include <widget_install/task_file_manipulation.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/foreach.h>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <string>
+
+using namespace WrtDB;
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
+ DPL::TaskDecl<TaskFileManipulation>(this),
+ m_context(context)
+{
+ AddStep(&TaskFileManipulation::StepCreateDirs);
+ AddStep(&TaskFileManipulation::StepRenamePath);
+
+ AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
+}
+
+void TaskFileManipulation::StepCreateDirs()
+{
+ std::string widgetPath;
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
+
+ widgetPath = m_context.locations->getPackageInstallationDir();
+
+ std::string widgetBinPath = m_context.locations->getBinaryDir();
+ std::string widgetSrcPath = m_context.locations->getSourceDir();
+
+ _WrtMakeDir(widgetPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
+
+ // If package type is widget with osp service, we don't need to make bin
+ // and src directory
+ if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
+ LogDebug("Doesn't need to create resource directory");
+ } else {
+ LogDebug("Create resource directory");
+ _WrtMakeDir(widgetBinPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
+ _WrtMakeDir(widgetSrcPath.c_str(), 0755, WRT_FILEUTILS_RECUR);
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_DIR_CREATE,
+ "Widget Directory Created");
+}
+
+void TaskFileManipulation::StepRenamePath()
+{
+ std::string instDir;
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
+
+ if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
+ instDir = m_context.locations->getPackageInstallationDir();
+ } else {
+ instDir = m_context.locations->getSourceDir();
+ }
+
+ LogDebug("Copy file from temp directory to " << instDir);
+ if (!_WrtUtilRemoveDir(instDir.c_str())) {
+ ThrowMsg(Exceptions::RemovingFolderFailure,
+ "Error occurs during removing existing folder");
+ }
+
+ if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(), instDir.c_str()) == 0)) {
+ ThrowMsg(Exceptions::UnknownError,
+ "Error occurs during renaming widget folder");
+ }
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_RENAME_PATH,
+ "Widget Rename path Finished");
+}
+
+void TaskFileManipulation::StepAbortRenamePath()
+{
+ LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
+ Assert(!!m_context.widgetHandle);
+ std::string widgetPath;
+ if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
+ widgetPath = m_context.locations->getPackageInstallationDir();
+ } else {
+ widgetPath = m_context.locations->getSourceDir();
+ }
+ struct stat fileInfo;
+ if (stat(widgetPath.c_str(), &fileInfo) != 0) {
+ LogError("Failed to get widget file path : " << widgetPath);
+ return;
+ }
+
+ if (!(rename(widgetPath.c_str(), m_context.locations->getTemporaryPackageDir().c_str()) == 0)) {
+ LogError("Failed to rename");
+ }
+ LogDebug("Rename widget path sucessful!");
+}
+} //namespace WidgetInstall
+} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 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 task_db_update.h
+ * @author Lukasz Wrzosek(l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief Header file for installer task database updating
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_FILE_MANIPULATION_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_FILE_MANIPULATION_UPDATE_H
+
+#include <dpl/task.h>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskFileManipulation :
+ public DPL::TaskDecl<TaskFileManipulation>
+{
+ private:
+ InstallerContext& m_context;
+
+ void StepCreateDirs();
+ void StepRenamePath();
+
+ void StepAbortRenamePath();
+
+ public:
+ TaskFileManipulation(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_FILE_MANIPULATION_H
LogInfo("Step: installation for osp service");
std::ostringstream commStr;
- commStr << OSP_INSTALL_STR << GlobalConfig::GetUserInstalledWidgetPath();
- commStr << "/" << m_context.widgetConfig.pkgname;
+ commStr << OSP_INSTALL_STR << m_context.locations->getPackageInstallationDir();
//commStr << " 2>&1";
LogDebug("osp install command : " << commStr.str());
ThrowMsg(Exceptions::InternalError, "No Package name exists.");
}
- real_path << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- real_path << pkgname << "/";
- real_path << GlobalConfig::GetUserWidgetExecPath() << "/" <<
- m_context.widgetHandle;
+ real_path << m_context.locations->getBinaryDir() << "/" << m_context.widgetHandle;
std::string clientExeStr = GlobalConfig::GetWrtClientExec();
LogInfo("link -s " << clientExeStr << " " << real_path.str());
std::ostringstream targetFile;
if (!!src) {
- if (m_context.browserRequest) {
- size_t pos = m_context.widgetSource.rfind("/");
- sourceFile << m_context.widgetSource.substr(0, pos+1);
- } else {
- sourceFile << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- sourceFile << pkgname << "/";
- sourceFile << GlobalConfig::GetWidgetSrcPath() << "/";
- }
+
+ sourceFile << m_context.locations->getSourceDir() << "/";
if (!i.empty()) {
sourceFile << "locales/" << i << "/";
targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
targetFile << getIconTargetFilename(i);
- if (m_context.browserRequest) {
- m_context.installedIconPath = targetFile.str();
+ if (m_context.locations->browserRequest())
+ {
+ m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
}
+
} else {
//Use WRT default (not from the widget) only if widget default (not
// localized) doesn't exist.
{
LogDebug("Backup Icon Files");
- backup_dir << GlobalConfig::GetUserInstalledWidgetPath();
- backup_dir << "/" << m_context.widgetConfig.pkgname;
+ backup_dir << m_context.locations->getPackageInstallationDir();
backup_dir << "/" << "backup" << "/";
backupIconFiles();
LogInfo("Finished ManifestFile step");
}
+
void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
const DPL::String& key,
const DPL::String& languageTag)
}
std::ostringstream path;
- path << GlobalConfig::GetUserInstalledWidgetPath() << "/" << *pkgname << "/";
- path << GlobalConfig::GetUserWidgetExecPath() << "/" << *m_context.widgetHandle;
+ path << m_context.locations->getBinaryDir() << "/" << *m_context.widgetHandle;
uiApp.setExec(DPL::FromASCIIString(path.str()));
}
}
}
-void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, int iconId, const WrtDB::WidgetDAOReadOnly::WidgetIconList & list, bool & defaultIconSaved)
+void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag,
+ const DPL::String& language, int iconId, const WrtDB::WidgetDAOReadOnly::WidgetIconList & list,
+ bool & defaultIconSaved)
{
DPL::String locale;
if (!!tag)
}
if (!!src) {
DPL::String iconText;
- iconText += /*DPL::FromASCIIString(GlobalConfig::GetUserWidgetDesktopIconPath()) + L"/" +*/ getIconTargetFilename(language);
+ iconText += getIconTargetFilename(language);
+
if(!locale.empty())
{
uiApp.addIcon(IconType(iconText,locale));
void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
{
uiApp.setNodisplay(false);
- //TODO(t.iwanek):
- //There is no "X-TIZEN-PackageType=wgt", there is not field in manifest
+ //TODO
+ //There is no "X-TIZEN-PackageType=wgt"
//There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str()
//There is no Comment in pkgmgr "Comment=Widget application"
+ //that were in desktop file
}
void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
//for widget update
void backupIconFiles();
void getFileList(const char* path, std::list<std::string> &list);
+ DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
static void saveLocalizedKey(std::ofstream &file,
const DPL::String& key,
const DPL::String& languageTag);
- DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
static const char * encoding;
m_installerContext(installerContext)
{
// Install steps
- AddStep(&TaskPrepareFiles::StepCreateTempPath);
AddStep(&TaskPrepareFiles::StepCopyFiles);
-
- AddAbortStep(&TaskPrepareFiles::StepAbort);
-}
-
-void TaskPrepareFiles::StepCreateTempPath()
-{
- /*
- * Config.xml and all icons will be copied to another location so the path
- * has to be updated.
- */
- m_installerContext.tempWidgetPath = createTempPath();
}
void TaskPrepareFiles::CopyFile(const std::string& source)
if(last != std::string::npos) {
filename = source.substr( last+1 );
}
- std::string target = m_installerContext.tempWidgetPath + '/' + filename;
+ std::string target = m_installerContext.locations->getTemporaryPackageDir() + '/' + filename;
LogDebug("source " << source);
LogDebug("target " << target);
void TaskPrepareFiles::StepCopyFiles()
{
- CopyFile(m_installerContext.widgetSource);
+ CopyFile(m_installerContext.locations->getWidgetSource());
- size_t last = m_installerContext.widgetSource.find_last_of("\\/");
+ size_t last = m_installerContext.locations->getWidgetSource().find_last_of("\\/");
std::string sourceDir = "";
if (last != std::string::npos) {
- sourceDir = m_installerContext.widgetSource.substr(0,last+1);
+ sourceDir = m_installerContext.locations->getWidgetSource().substr(0,last+1);
}
+ LogDebug("Icons copy...");
FOREACH(it, m_installerContext.widgetConfig.configInfo.iconsList) {
std::ostringstream os;
+ LogDebug("Coping: " << sourceDir << DPL::ToUTF8String(it->src));
os << sourceDir << DPL::ToUTF8String(it->src);
CopyFile(os.str());
}
}
-void TaskPrepareFiles::StepAbort()
-{
- removeTemporaryDir(m_installerContext.tempWidgetPath);
-}
-
} // namespace WidgetInstall
} // namespace Jobs
void CopyFile(const std::string& source);
// Steps
- void StepCreateTempPath();
void StepCopyFiles();
- void StepAbort();
public:
explicit TaskPrepareFiles(InstallerContext &installerContext);
std::ostringstream widgetPath;
DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
if(!pkgname.IsNull()) {
- widgetPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- widgetPath << pkgname << "/";
+ widgetPath << m_context.locations->getPackageInstallationDir() << "/";
} else {
ThrowMsg(Exceptions::InternalError, "No Package name exists.");
}
{
LogInfo("Step: create information file for recovery");
- std::string fileName;
- size_t pos = m_context.widgetSource.rfind("/");
+ size_t pos = m_context.locations->getWidgetSource().rfind("/");
std::ostringstream infoPath;
infoPath << GlobalConfig::GetTempInstallInfoPath();
infoPath << "/";
- infoPath << m_context.widgetSource.substr(pos+1);
+ infoPath << m_context.locations->getWidgetSource().substr(pos+1);
FILE *temp = fopen(infoPath.str().c_str(), "w+");
if (temp != NULL) {
- fputs(m_context.widgetSource.c_str(), temp);
+ fputs(m_context.locations->getWidgetSource().c_str(), temp);
fsync(temp->_fileno);
fclose(temp);
void TaskRemoveBackupFiles::StepRemoveBackupFiles()
{
std::ostringstream backupDir;
- backupDir << GlobalConfig::GetUserInstalledWidgetPath();
- backupDir << "/" << m_context.widgetConfig.pkgname << "/" << "backup";
+ backupDir << m_context.locations->getBackupDir();
if (_WrtUtilRemoveDir(backupDir.str().c_str())) {
LogDebug("Success to remove backup files : " << backupDir.str());
"Error occurs during removing existing folder");
}
- if (_WrtUtilRemoveDir(m_context.tempWidgetPath.c_str())) {
- LogDebug("Success to remove temp directory : " <<
- m_context.tempWidgetPath);
+ std::string tmp = m_context.locations->getTemporaryPackageDir();
+ if (_WrtUtilRemoveDir(tmp.c_str())) {
+ LogDebug("Success to remove temp directory : " << tmp);
} else {
- LogDebug("Failed to remove temp directory : " <<
- m_context.tempWidgetPath);
+ LogDebug("Failed to remove temp directory : " << tmp);
ThrowMsg(Exceptions::RemoveBackupFailed,
"Error occurs during removing existing folder");
}
m_installerContext(installerContext)
{
// Install steps
- AddStep(&TaskUnzip::StepCreateTempPath);
AddStep(&TaskUnzip::StepUnzipPrepare);
AddStep(&TaskUnzip::StepUnzipProgress);
AddStep(&TaskUnzip::StepUnzipFinished);
-
- AddAbortStep(&TaskUnzip::StepAbort);
}
void TaskUnzip::ExtractFile(DPL::ZipInput::File *input,
}
}
-void TaskUnzip::StepCreateTempPath()
-{
- // Step succedded, save temporary widget path
- m_installerContext.tempWidgetPath = createTempPath();
- std::ostringstream path;
-
- if (m_installerContext.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
- std::ostringstream tempRoot;
- tempRoot << m_installerContext.tempWidgetPath;
- tempRoot << "/" << GlobalConfig::GetWidgetSrcPath();
- m_installerContext.tempWidgetRoot = tempRoot.str();
-
- path << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- path << m_installerContext.widgetConfig.pkgname;
- } else {
- m_installerContext.tempWidgetRoot = m_installerContext.tempWidgetPath;
- path << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- path << m_installerContext.widgetConfig.pkgname << "/";
- path << GlobalConfig::GetWidgetSrcPath();
- }
- m_installerContext.installPath = path.str();
-
- m_installerContext.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_TEMPDIR,
- "Create temporary directory for unzip");
-}
-
void TaskUnzip::StepUnzipPrepare()
{
LogInfo("Prepare to unzip...");
Try
{
- m_zip.Reset(new DPL::ZipInput(m_installerContext.widgetSource));
+ m_zip.Reset(new DPL::ZipInput(m_installerContext.locations->getWidgetSource()));
LogInfo("Widget package comment: " << m_zip->GetGlobalComment());
// Widget package must not be empty
if (m_zip->empty()) {
- ThrowMsg(Exceptions::ZipEmpty, m_installerContext.widgetSource);
+ ThrowMsg(Exceptions::ZipEmpty, m_installerContext.locations->getWidgetSource());
}
// Set iterator to first file
}
Catch(DPL::ZipInput::Exception::OpenFailed)
{
- ReThrowMsg(Exceptions::OpenZipFailed, m_installerContext.widgetSource);
+ ReThrowMsg(Exceptions::OpenZipFailed, m_installerContext.locations->getWidgetSource());
}
}
if (fileName[fileName.size() - 1] == '/') {
// This is path
- std::string newPath = m_installerContext.tempWidgetPath + "/" +
+ std::string newPath = m_installerContext.locations->getTemporaryPackageDir() + "/" +
fileName.substr(0, fileName.size() - 1);
LogPedantic("Path to extract: " << newPath);
} else {
// This is regular file
std::string fileExtractPath =
- m_installerContext.tempWidgetPath + "/" + fileName;
+ m_installerContext.locations->getTemporaryPackageDir() + "/" + fileName;
LogPedantic("File to extract: " << fileExtractPath);
LogInfo("Unzip finished");
}
-void TaskUnzip::StepAbort()
-{
- removeTemporaryDir(m_installerContext.tempWidgetPath);
-}
} //namespace WidgetInstall
} //namespace Jobs
void EncryptionFile(const std::string &fileName);
// Steps
- void StepCreateTempPath();
-
void StepUnzipPrepare();
void StepUnzipProgress();
void StepUnzipFinished();
- void StepAbort();
public:
TaskUnzip(InstallerContext &installerContext);
LogDebug("StepCreateBackupFolder");
std::ostringstream backDirPath;
- backDirPath << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-
- backDirPath << pkgname;
- m_pkgPath = backDirPath.str();
-
- backDirPath << "/" << GetWidgetBackupDirPath() << "/";
+ backDirPath << m_context.locations->getBackupDir();
m_srcBuPath = backDirPath.str() + GlobalConfig::GetWidgetSrcPath();
LogDebug("backup resource directory path : " << m_srcBuPath);
if(!_WrtMakeDir(m_srcBuPath.c_str(), 0755, WRT_FILEUTILS_RECUR)) {
ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str())+1);
- std::string tempSrc = m_context.tempWidgetPath;
- ReadDirList(tempSrc, tempList, strlen(m_context.tempWidgetPath.c_str())+1);
+ std::string tempSrc = m_context.locations->getTemporaryPackageDir();
+ ReadDirList(tempSrc, tempList, strlen(tempSrc.c_str())+1);
FOREACH(it, tempList) {
std::set<std::string>::iterator res;
{
LogDebug("StepAbortCreateBackupFolder");
std::ostringstream path;
- path << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- path << m_context.widgetConfig.pkgname << "/";
- path << GetWidgetBackupDirPath();
+ path << m_context.locations->getBackupDir();
LogDebug("Remove backup directory : " << path.str());
if(!_WrtUtilRemoveDir(path.str().c_str())) {
* @version 1.0
* @brief Implementation file for installer task widget config
*/
-#include <string>
+
#include <sstream>
-#include <dpl/foreach.h>
+#include <string>
+#include <sys/stat.h>
+#include <dirent.h>
+
#include <dpl/errno_string.h>
-#include <dpl/wrt-dao-rw/feature_dao.h>
-#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/foreach.h>
+#include <dpl/localization/w3c_file_localization.h>
+#include <dpl/singleton_impl.h>
+#include <dpl/utils/file_utils.h>
+#include <dpl/utils/mime_type_utils.h>
+#include <dpl/utils/wrt_global_settings.h>
#include <dpl/utils/wrt_utility.h>
-#include <root_parser.h>
-#include <widget_parser.h>
-#include <parser_runner.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-rw/feature_dao.h>
+
#include <libiriwrapper.h>
-#include <widget_install/task_widget_config.h>
+#include <parser_runner.h>
+#include <root_parser.h>
+
#include <widget_install/job_widget_install.h>
-#include <widget_install/widget_install_errors.h>
+#include <widget_install/task_widget_config.h>
#include <widget_install/widget_install_context.h>
-#include <dpl/utils/file_utils.h>
-#include <dpl/utils/mime_type_utils.h>
-#include <sys/stat.h>
-#include <dpl/utils/wrt_global_settings.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_parser.h>
+#include <wrt_error.h>
+
namespace { // anonymous
const WidgetHandle WIDGET_HANDLE_START_VALUE = 1000;
const std::string WIDGET_NOT_COMPATIBLE = "This widget is "
"not compatible with WRT.<br><br>";
const std::string QUESTION = "Do you want to install it anyway?";
-} // namespace anonymous
+
+const char *const DEFAULT_LANGUAGE = "default";
+const size_t MAX_WIDGET_PATH_SIZE = 1024;
+
+const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
+}
+
namespace Jobs {
namespace WidgetInstall {
{
Try
{
- std::string path;
- LogInfo("path: " << m_installContext.tempWidgetRoot);
- if (m_installContext.browserRequest) {
- path = m_installContext.widgetSource;
- } else {
- path = m_installContext.tempWidgetRoot;
- }
+ std::string path = m_installContext.locations->getConfigurationDir();
+ LogInfo("path: " << path);
- WidgetConfigurationManagerSingleton::Instance().processFile(
- path,
- m_installContext.widgetConfig);
+ processFile(path, m_installContext.widgetConfig);
}
- Catch(WidgetConfigurationManager::Exception::ProcessFailed)
+ Catch(Exception::ConfigParseFailed)
{
LogError("Parsing failed.");
ReThrow(Exceptions::WidgetConfigFileInvalid);
// To get widget type for distribute WAC, TIZEN WebApp
setApplicationType();
}
- Catch(WidgetConfigurationManager::Exception::ProcessFailed)
+ Catch(Exception::ConfigParseFailed)
{
LogError("Config.xml has more than one namespace");
ReThrow(Exceptions::WidgetConfigFileInvalid);
//Adding default locale
m_localeFolders.insert(L"");
- std::string localePath = m_installContext.tempWidgetRoot + "/locales";
+ std::string localePath = m_installContext.locations->getConfigurationDir() + "/locales";
DIR* localeDir = opendir(localePath.c_str());
if (!localeDir) {
LogDebug("No /locales directory in the widget package.");
DPL::String relativePath = pathPrefix + *path;
DPL::String absolutePath = DPL::FromUTF8String(
- m_installContext.tempWidgetRoot) + L"/" + relativePath;
+ m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
// get property data from packaged app
if (FileUtils::FileExists(absolutePath)) {
}
DPL::String relativePath = pathPrefix + icon.src;
- DPL::String absolutePath;
-
- if (m_installContext.browserRequest) {
- // in case of browser installation
- size_t pos = m_installContext.widgetSource.rfind("/");
- absolutePath = DPL::FromUTF8String(
- m_installContext.widgetSource.substr(0, pos));
- } else {
- absolutePath = DPL::FromUTF8String(
- m_installContext.tempWidgetRoot);
- }
- absolutePath += L"/" + relativePath;
+ DPL::String absolutePath = DPL::FromUTF8String(
+ m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
if (FileUtils::FileExists(absolutePath)) {
DPL::String type = MimeTypeUtils::identifyFileMimeType(absolutePath);
return ret;
}
+bool TaskWidgetConfig::parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
+ const std::string& _currentPath, int* pErrCode)
+{
+ ParserRunner parser;
+ Try
+ {
+ parser.Parse(_currentPath, ElementParserPtr(new
+ RootParser<
+ WidgetParser>(
+ configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
+ }
+ Catch(ElementParser::Exception::Base)
+ {
+ LogDebug("Invalid widget configuration file!");
+ *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+ return false;
+ }
+ return true;
+}
+
+bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
+ const std::string& _currentPath, int* pErrCode)
+{
+ ParserRunner parser;
+
+ //TODO: rewrite this madness
+ char cfgAbsPath[MAX_WIDGET_PATH_SIZE + 1] = { 0 };
+ DIR* dir = NULL;
+ struct dirent* ptr = NULL;
+
+ dir = opendir(_currentPath.c_str());
+ if (dir == NULL) {
+ *pErrCode = WRT_ERR_UNKNOWN;
+ return false;
+ }
+ bool has_config_xml = false;
+ errno = 0;
+ while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name
+ if (ptr->d_type == DT_REG) {
+ if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
+ _WrtUtilSetAbsolutePath(cfgAbsPath,
+ _currentPath.c_str(), ptr->d_name);
+ //Parse widget configuration file
+ LogDebug("Found config: " << cfgAbsPath);
+
+ Try
+ {
+ parser.Parse(cfgAbsPath, ElementParserPtr(new
+ RootParser<
+ WidgetParser>(
+ configInfo,
+ DPL
+ ::
+ FromUTF32String(
+ L"widget"))));
+ }
+ Catch(ElementParser::Exception::Base)
+ {
+ LogDebug("Invalid widget configuration file!");
+ // _rethrown_exception.Dump();
+ *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+ closedir(dir);
+ return false;
+ }
+
+ has_config_xml = true;
+ break;
+ }
+ }
+ }
+ closedir(dir);
+
+ //We must have config.xml so leaveing if we doesn't
+ if (!has_config_xml) {
+ LogDebug("Invalid archive");
+ *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+ return false;
+ }
+ return true;
+}
+
+bool TaskWidgetConfig::locateAndParseConfigurationFile(
+ const std::string& _currentPath,
+ WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+ const std::string& baseFolder,
+ int* pErrCode)
+{
+ using namespace WrtDB;
+
+ if (!pErrCode) {
+ return false;
+ }
+
+ ConfigParserData& configInfo = pWidgetConfigInfo.configInfo;
+
+ // check if this installation from browser, or not.
+ size_t pos = _currentPath.rfind("/");
+ std::ostringstream infoPath;
+ infoPath << _currentPath.substr(pos+1);
+
+ std::string language = "";
+
+ if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) {
+ if (_currentPath.empty() || baseFolder.empty()) {
+ *pErrCode = WRT_ERR_INVALID_ARG;
+ return false;
+ }
+ // in case of general installation using wgt archive
+ if(!parseConfigurationFileWidget(configInfo, _currentPath, pErrCode))
+ {
+ return false;
+ }
+ } else {
+ // in case of browser installation
+ if(!parseConfigurationFileBrowser(configInfo, _currentPath, pErrCode))
+ {
+ return false;
+ }
+ }
+
+ char *tmp_language;
+ if (!_WrtUtilStringToLower(baseFolder.c_str(), &tmp_language)) {
+ *pErrCode = WRT_ERR_UNKNOWN;
+ return false;
+ }
+
+ if (!tmp_language) {
+ *pErrCode = WRT_ERR_UNKNOWN;
+ return false;
+ }
+ language = tmp_language;
+ free(tmp_language);
+
+ if(!fillWidgetConfig(pWidgetConfigInfo, configInfo))
+ {
+ *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+ return false;
+ }
+ return true;
+}
+
+bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+ WrtDB::ConfigParserData& configInfo)
+{
+ if (!!configInfo.widget_id) {
+ if (!pWidgetConfigInfo.guid) {
+ pWidgetConfigInfo.guid = configInfo.widget_id;
+ } else {
+ if (pWidgetConfigInfo.guid != configInfo.widget_id) {
+ LogDebug("Invalid archive");
+ return false;
+ }
+ }
+ }
+ if (!!configInfo.tizenId) {
+ if (!pWidgetConfigInfo.pkgname) {
+ pWidgetConfigInfo.pkgname = configInfo.tizenId;
+ } else {
+ if (pWidgetConfigInfo.pkgname != configInfo.tizenId) {
+ LogDebug("Invalid archive - Tizen ID not same error");
+ return false;
+ }
+ }
+ }
+ if (!!configInfo.version) {
+ if (!pWidgetConfigInfo.version) {
+ pWidgetConfigInfo.version = configInfo.version;
+ } else {
+ if (pWidgetConfigInfo.version != configInfo.version) {
+ LogDebug("Invalid archive");
+ return false;
+ }
+ }
+ }
+ if (!!configInfo.minVersionRequired) {
+ pWidgetConfigInfo.minVersion = configInfo.minVersionRequired;
+ } else if (!!configInfo.tizenMinVersionRequired) {
+ pWidgetConfigInfo.minVersion = configInfo.tizenMinVersionRequired;
+ }
+ return true;
+}
+
+void TaskWidgetConfig::processFile(const std::string& path,
+ WrtDB::WidgetRegisterInfo &widgetConfiguration)
+{
+ int pErrCode;
+
+ if (!locateAndParseConfigurationFile(path, widgetConfiguration,
+ DEFAULT_LANGUAGE, &pErrCode)) {
+ LogWarning("Widget archive: Failed while parsing config file");
+ ThrowMsg(Exception::ConfigParseFailed, path);
+ }
+}
+
} //namespace WidgetInstall
} //namespace Jobs
* limitations under the License.
*/
/*
- * @file task_widget_config.cpp
+ * @file task_widget_config.h
* @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
* @version 1.0
* @brief Implementation file for installer task widget config
#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
-#include <WidgetConfigurationManager.h>
+#include <set>
+#include <list>
+
#include <dpl/task.h>
#include <dpl/task_list.h>
#include <dpl/string.h>
-#include <wrt_error.h>
+#include <dpl/optional.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/wrt-dao-ro/global_config.h>
-#include <set>
+
+#include <wrt_error.h>
#include <wrt_common_types.h>
#include <widget_install/widget_install_popup.h>
public WidgetInstallPopup
{
private:
+ class Exception
+ {
+ public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, ConfigParseFailed)
+ };
+
+ typedef std::list<std::pair<DPL::String, DPL::String> > StringPairList;
+
InstallerContext& m_installContext;
WrtDB::LocaleSet m_localeFolders;
std::set<DPL::String> m_processedIconSet;
bool isTizenWebApp() const;
bool parseVersionString(const std::string &version, long &majorVersion,
long &minorVersion, long µVersion) const;
+ /**
+ * This method is used to process the config.xml of widget, get
+ * the corresponding configuration to pWidgetConfigInfo
+ *
+ * @param[in] path Specified the widget archive file path (absolute path).
+ * @return Configuration information of widget
+ */
+ void processFile(const std::string& path,
+ WrtDB::WidgetRegisterInfo &wConfig);
+ bool locateAndParseConfigurationFile(const std::string& currentPath,
+ WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+ const std::string& baseFolder,
+ int* pErrCode);
+ bool parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
+ const std::string& _currentPath, int* pErrCode);
+ bool parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
+ const std::string& _currentPath, int* pErrCode);
+ bool fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+ WrtDB::ConfigParserData& configInfo);
public:
TaskWidgetConfig(InstallerContext& installTaskContext);
};
#include <widget_install/wac_security.h>
#include <feature_logic.h>
#include <widget_install/widget_update_info.h>
+#include <widget_location.h>
namespace Jobs {
namespace WidgetInstall {
} InstallStep;
// Installation state variables
- std::string widgetSource; ///< Source widget zip file/widget url
- std::string tempWidgetPath; ///< Unpacked widget temporary path
- bool browserRequest; ///< Browser Request
- std::string installedIconPath; ///< Installed icon path
WrtDB::WidgetRegisterInfo widgetConfig; ///< WidgetConfigInfo
DPL::Optional<WrtDB::DbWidgetHandle> widgetHandle;
+ DPL::Optional<WidgetLocation> locations;
Jobs::WidgetInstall::WacSecurity wacSecurity;///< Widget Domain information.
InstallStep installStep; ///< current step of installation
Jobs::WidgetInstall::JobWidgetInstall *job;
RequestedDevCapsMap staticPermittedDevCaps;
std::string installInfo; ///<For recovery>
bool m_quiet;
-
- std::string tempWidgetRoot; ///< temporary widget root path
- std::string installPath; ///< widget install path
};
#endif // INSTALLER_CONTEXT_H
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#include <dpl/utils/file_utils.h>
+
#include <widget_uninstall/job_widget_uninstall.h>
#include <widget_uninstall/widget_uninstall_errors.h>
#include <widget_uninstall/task_check.h>
m_context.uninstallStep = UninstallerContext::UNINSTALL_START;
m_context.job = this;
- Try {
+ Try
+ {
WrtDB::WidgetDAOReadOnly dao(widgetHandle);
m_context.pkgname = DPL::ToUTF8String(*dao.getPkgname());
+ m_context.locations = WidgetLocation(m_context.pkgname);
+
LogInfo("Widget model exists. Pkg name: " << m_context.pkgname);
AddTask(new TaskSmack(m_context));
PKGMGR_START_KEY,
PKGMGR_START_UNINSTALL);
}
-
+ } Catch(FileUtils::CreateDirectoryException) {
+ LogError("Failed to create temporary path for widget");
+ AddTask(new UninstallerTaskFail(false));
} Catch (WidgetDAOReadOnly::Exception::WidgetNotExist) {
AddTask(new UninstallerTaskFail(true));
} Catch (WidgetDAOReadOnly::Exception::Base) {
#include <widget_uninstall/task_remove_files.h>
#include <widget_uninstall/job_widget_uninstall.h>
+#include <widget_uninstall/uninstaller_context.h>
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/wrt-dao-ro/widget_config.h>
std::ostringstream widgetDir;
- widgetDir << GlobalConfig::GetUserInstalledWidgetPath() << "/";
- widgetDir << m_context.pkgname << "/";
+ widgetDir << m_context.locations->getPackageInstallationDir() << "/";
uninstRootDir = widgetDir.str();
ReadDir(uninstRootDir, filesList);
#ifndef WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_REMOVE_FILES_H_
#define WRT_SRC_INSTALLER_CORE_JOB_WIDGET_UNINSTALL_TASK_REMOVE_FILES_H_
-#include <dpl/task.h>
+//forward declaration
+struct UninstallerContext;
-#include <widget_uninstall/uninstaller_context.h> //TODO forward decl
+#include <dpl/task.h>
+#include <dpl/log/log.h>
#include <string>
#include <string>
#include <widget_uninstall/widget_uninstaller_struct.h>
+#include <widget_location.h>
namespace Jobs {
namespace WidgetUninstall {
///< flag that indicates whether installer finishes
//to remove files completely.
bool removeFinished;
+
+ DPL::Optional<WidgetLocation> locations;
+
UninstallStep uninstallStep; ///< current step of installation
Jobs::WidgetUninstall::JobWidgetUninstall *job;
std::string pkgname;
#include "installer_controller.h"
#include <dpl/log/log.h>
#include <dpl/singleton_impl.h>
-IMPLEMENT_SINGLETON(InstallerController)
+
+IMPLEMENT_SINGLETON(Logic::InstallerController)
+
+namespace Logic
+{
InstallerController::InstallerController()
{
{
m_installerLogic.Terminate();
}
+
+} //Logic
+
} // namespace InstallerEvents
+
+namespace Logic {
+
/**
* @brief Controls Widget installation
*
private:
// Embedded logic
- InstallerLogic m_installerLogic;
+ Logic::InstallerLogic m_installerLogic;
InstallerController();
typedef DPL::Singleton<InstallerController> InstallerControllerSingleton;
+}
+
#endif // INSTALLER_CONTROLLER_H
using namespace WrtDB;
+namespace Logic {
+
InstallerLogic::InstallerLogic() :
m_NextHandle(0)
{
return true;
}
+}
+
#include <plugin_install/plugin_installer_struct.h>
#include <job.h>
-//TODO create namespace
+namespace Logic {
class InstallerLogic
{
friend class InstallerController;
};
+}
+
#endif // INSTALLER_LOGIC_H
isInitialized = true;
LogDebug("Libxml have been initialized");
}
- LogDebug("Libxml already inited");
+ LogDebug("Libxml already initialized");
}
--- /dev/null
+/*
+ * Copyright (c) 2011 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 widget_location.cpp
+ * @author Iwanek Tomasz (t.iwanek@smasung.com)
+ */
+#include "widget_location.h"
+
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/assert.h>
+#include <dpl/log/log.h>
+#include <dpl/sstream.h>
+#include <dpl/localization/localization_utils.h>
+
+#include <widget_install/task_commons.h>
+
+
+WidgetLocation::DirectoryDeletor::DirectoryDeletor()
+{
+ m_dirpath = Jobs::WidgetInstall::createTempPath();
+}
+
+WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
+{
+ LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
+ _WrtUtilRemoveDir(m_dirpath.c_str());
+}
+
+std::string WidgetLocation::DirectoryDeletor::getTempPath() const
+{
+ return m_dirpath;
+}
+
+WidgetLocation::WidgetLocation() : m_browser(false)
+{
+}
+
+WidgetLocation::WidgetLocation(const std::string & widgetname) : m_pkgname(widgetname), m_browser(false)
+{
+}
+
+WidgetLocation::~WidgetLocation()
+{
+}
+
+WidgetLocation::WidgetLocation(const std::string & widgetname,
+ std::string sourcePath,
+ bool browserRequest,
+ WrtDB::PkgType t):
+ m_pkgname(widgetname),
+ m_widgetSource(sourcePath),
+ m_browser(browserRequest),
+ m_type(t),
+ m_temp(new WidgetLocation::DirectoryDeletor())
+{
+}
+
+std::string WidgetLocation::getInstallationDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath());
+}
+
+std::string WidgetLocation::getPackageInstallationDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ + m_pkgname;
+}
+
+std::string WidgetLocation::getSourceDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ + m_pkgname + "/" + WrtDB::GlobalConfig::GetWidgetSrcPath();
+}
+
+std::string WidgetLocation::getBinaryDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ + m_pkgname + "/" + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+}
+
+std::string WidgetLocation::getBackupDir() const
+{
+ return getPackageInstallationDir() + "/backup";
+}
+
+std::string WidgetLocation::getTemporaryPackageDir() const
+{
+ return m_temp->getTempPath();
+}
+
+bool WidgetLocation::browserRequest() const
+{
+ return m_browser;
+}
+
+std::string WidgetLocation::getTemporaryRootDir() const
+{
+ if(m_type == WrtDB::PKG_TYPE_TIZEN_WITHSVCAPP)
+ {
+ return getTemporaryPackageDir() + "/" + WrtDB::GlobalConfig::GetWidgetSrcPath();
+ }
+ else
+ {
+ return getTemporaryPackageDir();
+ }
+}
+
+std::string WidgetLocation::getConfigurationDir() const
+{
+ if(m_browser)
+ {
+ std::string path = ".";
+ int index = m_widgetSource.find_last_of("\\/");
+ if (index != std::string::npos)
+ {
+ path = m_widgetSource.substr(0, index);
+ }
+ return path;
+ }
+ else
+ {
+ return getTemporaryRootDir();
+ }
+}
+
+std::string WidgetLocation::getInstalledIconPath() const
+{
+ return m_iconPath;
+}
+
+std::string WidgetLocation::getWidgetSource() const
+{
+ return m_widgetSource;
+}
+
+void WidgetLocation::setIconTargetFilenameForLocale(const std::string & icon)
+{
+ m_iconPath = icon;
+}
--- /dev/null
+/*
+ * Copyright (c) 2011 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 widget_location.h
+ * @author Iwanek Tomasz (t.iwanek@smasung.com)
+ */
+#ifndef WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
+#define WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
+
+#include <string>
+
+#include <dpl/shared_ptr.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+
+/**
+ * @brief The WidgetLocation class
+ *
+ * Object that stores locations of several files/directories according
+ * to package name
+ *
+ * Current package layout (of installed package) is following:
+ *
+ * /opt/apps/[package_name]
+ * \_____________ /data
+ * \_____________ /bin
+ * \_____________ /bin/[id_of_installed_package]
+ * \_____________ /res/wgt/
+ * \___ config.xml
+ * \___ [widgets_archive_content]
+ *
+ * 1) Normal Widget
+ * Developer provides content of res/wgt directory (package contains that directory as root).
+ *
+ * 2) For OSP Service Hybrid App is actually a bit different:
+ * Root is OSP Service directory, WebApp content is located in [root]/res/wgt
+ *
+ * Temporary directory is directory when widget is placed at the begining
+ * of installation process. After parsing process of config.xml, destination directory is created.
+ */
+class WidgetLocation
+{
+ class DirectoryDeletor
+ {
+ public:
+ DirectoryDeletor();
+ ~DirectoryDeletor();
+ std::string getTempPath() const;
+ private:
+ std::string m_dirpath;
+ };
+
+public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
+ /**
+ * @brief WidgetLocation
+ *
+ * Creates useless object. Needed by DPL::Optional
+ */
+ WidgetLocation();
+ /**
+ * @brief WidgetLocation Builds paths for widget location during uninstallation
+ *
+ * Uninstallation process needs only installed package directory.
+ *
+ * @param widgetname name of widget
+ */
+ WidgetLocation(const std::string & widgetname);
+ /**
+ * @brief WidgetLocation Builds paths for widget location during installation
+ *
+ * @param widgetname name of widget
+ * @param browserRequest is browser Request
+ * @param sourcePath given source path
+ * @param t declaraced type of widget if type is needed
+ *
+ * In destruction removes temporary directory
+ */
+ WidgetLocation(const std::string & widgetname, std::string sourcePath,
+ bool browserRequest = false, WrtDB::PkgType t = WrtDB::PKG_TYPE_TIZEN_WEBAPP);
+ ~WidgetLocation();
+
+ // Installed paths
+ std::string getInstallationDir() const; // /opt/apps
+ std::string getPackageInstallationDir() const; // /opt/apps/[package]
+ std::string getSourceDir() const; // /opt/apps/[package]/res/wgt
+ std::string getBinaryDir() const; // /opt/apps/[package]/bin
+ std::string getBackupDir() const; // /opt/apps/[package]/backup
+
+ bool browserRequest() const;
+
+ // Temporary paths
+ /**
+ * @brief getTemporaryRootDir
+ * @return value of root for developer's provide package (root of unpacked .wgt file)
+ */
+ std::string getTemporaryPackageDir() const;
+ /**
+ * @brief getTemporaryRootDir
+ *
+ * Value of this will differs according to type of installed widget.
+ *
+ * @return value of root for content in temporary directory to be copied into 'res/wgt'
+ */
+ std::string getTemporaryRootDir() const;
+ /**
+ * @brief getConfigurationDir Returns rott directory for configuration requirements
+ *
+ * 1) For packed widgets it is just root of unpacked sources
+ * 2) For browser installation it is directory name of widget passed to installer
+ *
+ * @return configuration directory
+ */
+ std::string getConfigurationDir() const;
+
+ //icons
+ /**
+ * @brief setIconTargetFilenameForLocale set installed ion path according to locale
+ * @param icon path of application icon
+ */
+ void setIconTargetFilenameForLocale(const std::string &icon);
+ /**
+ * @brief getIconTargetFilename gets icon path suffix for locale
+ * @param languageTag language tag
+ * @return value of suffix of path
+ */
+ DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
+ /**
+ * @brief getIconTargetFilename gets icon full path
+ * @param languageTag language tag
+ * @return value of full path
+ */
+ std::string getInstalledIconPath() const;
+
+ /**
+ * @brief getWidgetSourcePath return widget's source path given to installer
+ * @return value of source path
+ */
+ std::string getWidgetSource() const;
+
+private:
+ std::string m_widgetSource; // Source widget zip file/widget url
+ bool m_browser; // is browser request installation
+ std::string m_pkgname; //name of package
+ std::string m_iconPath; //installed icon path
+ WrtDB::PkgType m_type;
+ DPL::SharedPtr<DirectoryDeletor> m_temp; //directory
+};
+
+#endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
${WRT_INSTALLER_SOURCES}
)
-ADD_DEFINITIONS("-DSEPARATE_INSTALLER_FOR_DAO") # TODO do not use ifdefs!
ADD_DEFINITIONS(${WRT_INSTALLER_DEPS_CFLAGS})
TARGET_LINK_LIBRARIES(${TARGET_INSTALLER}
void InstallerMainThread::TouchArchitecture()
{
// Touch controller
- InstallerControllerSingleton::Instance().Touch();
+ Logic::InstallerControllerSingleton::Instance().Touch();
}
void InstallerMainThread::TouchArchitectureOnlyInstaller()
{
// Touch controller
- InstallerControllerSingleton::Instance().Touch();
+ Logic::InstallerControllerSingleton::Instance().Touch();
}
// Installer init
CONTROLLER_POST_SYNC_EVENT(
- InstallerController,
+ Logic::InstallerController,
InstallerControllerEvents::
InitializeEvent());
// Install deferred widget packages
CONTROLLER_POST_EVENT(
- InstallerController,
+ Logic::InstallerController,
InstallerControllerEvents::
InstallDeferredWidgetPackagesEvent());
// Installer termination
CONTROLLER_POST_SYNC_EVENT(
- InstallerController,
+ Logic::InstallerController,
InstallerControllerEvents::
TerminateEvent());
LogInfo("[WRT-API] INSTALL WIDGET: " << path);
// Post installation event
CONTROLLER_POST_EVENT(
- InstallerController,
+ Logic::InstallerController,
InstallerControllerEvents::InstallWidgetEvent(
path, WidgetInstallationStruct(
InstallerCallbacksTranslate::installFinishedCallback,
LogInfo("[WRT-API] UNINSTALL WIDGET: " << widget_handle);
// Post uninstallation event
CONTROLLER_POST_EVENT(
- InstallerController,
+ Logic::InstallerController,
InstallerControllerEvents::UninstallWidgetEvent(
widget_handle,
WidgetUninstallationStruct(
user_param, status_cb, progress_cb);
CONTROLLER_POST_EVENT(
- InstallerController,
+ Logic::InstallerController,
InstallerControllerEvents::InstallPluginEvent(
std::string(pluginDir),
PluginInstallerStruct(
}
CONTROLLER_POST_SYNC_EVENT(
- InstallerController,
+ Logic::InstallerController,
InstallerControllerEvents::
InitializeEvent());
// Installer termination
CONTROLLER_POST_SYNC_EVENT(
- InstallerController,
+ Logic::InstallerController,
InstallerControllerEvents::
TerminateEvent());