--- /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 wrt_install_mode.h
+ * @author Jihoon Chung (jihoon.chung@samgsung.com)
+ * @version
+ * @brief Definition file of widget install mode class
+ */
+
+#ifndef WRT_INSTALL_MODE_H
+#define WRT_INSTALL_MODE_H
+
+class InstallMode
+{
+ public:
+ enum class Command
+ {
+ INSTALL,
+ REINSTALL
+ };
+ enum class Location
+ {
+ INTERNAL,
+ EXTERNAL
+ };
+ enum class RootPath
+ {
+ RW,
+ RO
+ };
+ enum class ExtensionType
+ {
+ WGT,
+ DIR
+ };
+ enum class InstallTime
+ {
+ NORMAL,
+ PRELOAD
+ };
+
+ InstallMode(Command cmd = Command::INSTALL,
+ Location lo = Location::INTERNAL,
+ RootPath root = RootPath::RW,
+ ExtensionType extensionType = ExtensionType::WGT,
+ InstallTime time = InstallTime::NORMAL) :
+ command(cmd),
+ location(lo),
+ rootPath(root),
+ extension(extensionType),
+ installTime(time)
+ {};
+
+ Command command;
+ Location location;
+ RootPath rootPath;
+ ExtensionType extension;
+ InstallTime installTime;
+};
+
+#endif // WRT_INSTALL_MODE_H
+
JobContextBase<WidgetInstallationStruct>(installerStruct),
m_exceptionCaught(Jobs::Exceptions::Success)
{
+ m_installerContext.mode = m_jobStruct.m_installMode;
ConfigureResult result = PrePareInstallation(widgetPath);
if (result == ConfigureResult::Ok) {
LogInfo("Widget Update");
m_installerContext.job->SetProgressFlag(true);
- if (m_jobStruct.m_installMode ==
- InstallMode::REINSTALL_MODE_DIRECTORY)
+ if (m_installerContext.mode.command ==
+ InstallMode::Command::REINSTALL)
{
AddTask(new TaskPrepareReinstall(m_installerContext));
}
Try
{
std::string tempDir;
- if (m_jobStruct.m_installMode ==
- InstallMode::REINSTALL_MODE_DIRECTORY)
- {
+ if (m_installerContext.mode.extension == InstallMode::ExtensionType::DIR) {
std::ostringstream tempPathBuilder;
tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
} else {
tempDir =
Jobs::WidgetInstall::createTempPath(
- m_jobStruct.m_installMode ==
- InstallMode::INSTALL_MODE_PRELOAD);
+ m_installerContext.mode.installTime ==
+ InstallMode::InstallTime::PRELOAD);
}
m_isDRM = isDRMWidget(widgetPath);
tempDir,
m_installerContext.widgetConfig.packagingType,
m_isDRM,
- m_jobStruct.m_installMode ==
- InstallMode::REINSTALL_MODE_DIRECTORY);
+ m_installerContext.mode.command == InstallMode::Command::REINSTALL);
LogDebug("widget packaging type : " <<
m_installerContext.widgetConfig.packagingType.pkgType);
void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
const std::string& tempPath)
{
- if (m_jobStruct.m_installMode ==
- InstallMode::REINSTALL_MODE_DIRECTORY)
- {
- // replace widget path to installed path
- m_installerContext.locations =
- WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
- tzPkgid),
- widgetPath, tempPath,
- m_installerContext.widgetConfig.packagingType,
- m_installerContext.locationType);
- } else {
- m_installerContext.locations =
- WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
- tzPkgid),
- widgetPath, tempPath,
- m_installerContext.widgetConfig.packagingType,
- m_installerContext.locationType);
- }
+ m_installerContext.locations =
+ WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
+ tzPkgid),
+ widgetPath, tempPath,
+ m_installerContext.widgetConfig.packagingType,
+ m_installerContext.locationType);
m_installerContext.locations->registerAppid(
DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid));
m_installerContext.widgetConfig.tzAppid = update.tzAppId;
if (isUpperVersion(update.existingVersion, update.incomingVersion) ||
- (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY) ||
- (m_jobStruct.m_installMode == InstallMode::REINSTALL_MODE_DIRECTORY))
+ m_installerContext.mode.extension == InstallMode::ExtensionType::DIR)
{
LogInfo("Whether widget policy allow proceed ok");
return ConfigureResult::Updated;
const std::string &tempPath)
{
// Check installation type (direcotory/ or config.xml or widget.wgt)
- if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY ||
- m_jobStruct.m_installMode == InstallMode::REINSTALL_MODE_DIRECTORY)
- {
+ if (m_installerContext.mode.extension == InstallMode::ExtensionType::DIR) {
LogDebug("Install directly from directory");
return PKG_TYPE_DIRECTORY_WEB_APP;
}
{
m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
- if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_PRELOAD) {
+ if (m_installerContext.mode.installTime == InstallMode::InstallTime::PRELOAD) {
m_installerContext.locationType =
INSTALL_LOCATION_TYPE_PRELOAD;
} else {
ace_policy_result_t policyResult = ACE_DENY;
//TODO: remove dao.getHandle()
- if (m_context.job->getInstallerStruct().m_installMode
- == InstallMode::INSTALL_MODE_PRELOAD)
- {
+ if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) {
LogDebug("This widget is prealoaded. So ace check will be skiped");
policyResult = ACE_PERMIT;
} else {
result = validator.check(data, widgetPath);
- if (m_contextData.widgetConfig.packagingType
- == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP ||
- m_contextData.job->getInstallerStruct().m_installMode
- == InstallMode::INSTALL_MODE_PRELOAD)
+ if (m_contextData.widgetConfig.packagingType ==
+ WrtDB::PKG_TYPE_DIRECTORY_WEB_APP ||
+ m_contextData.mode.installTime ==
+ InstallMode::InstallTime::PRELOAD)
{
// In directory installation mode, the validation is skipped.
LogDebug("Create resource directory");
WrtUtilMakeDir(widgetBinPath);
WrtUtilMakeDir(widgetSrcPath);
- if (m_context.job->getInstallerStruct().m_installMode
- == InstallMode::INSTALL_MODE_PRELOAD)
- {
+ if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) {
std::string userWidgetDir = m_context.locations->getUserDataRootDir();
WrtUtilMakeDir(userWidgetDir);
}
void TaskFileManipulation::StepLinkForPreload()
{
- if (m_context.job->getInstallerStruct().m_installMode
- == InstallMode::INSTALL_MODE_PRELOAD)
- {
+ if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) {
std::string srcDir = m_context.locations->getUserDataRootDir() +
WrtDB::GlobalConfig::GetWidgetSrcPath();
LogDebug("Commiting manifest file : " << manifest_file);
std::ostringstream destFile;
- if (m_context.job->getInstallerStruct().m_installMode
- == InstallMode::INSTALL_MODE_PRELOAD)
- {
+ if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) {
destFile << "/usr/share/packages" << "/"; //TODO constant with path
} else {
destFile << "/opt/share/packages" << "/"; //TODO constant with path
const char* perm_list[0];
perm_list[0] = NULL;
#endif
- if (m_context.job->getInstallerStruct().m_installMode
- != InstallMode::INSTALL_MODE_PRELOAD)
- {
+ if (m_context.mode.installTime != InstallMode::InstallTime::PRELOAD) {
int result = app_add_permissions(
DPL::ToUTF8String(tzPkgid).c_str(), perm_list);
if (PC_OPERATION_SUCCESS != result) {
#endif
}
-void TaskSmack::SetEndofInstallation()
+void TaskSmack::SetEndofInstallation()
{
m_context.job->UpdateProgress(
InstallerContext::INSTALL_END,
#include <feature_logic.h>
#include <widget_install/widget_update_info.h>
#include <widget_location.h>
+#include <wrt_install_mode.h>
namespace Jobs {
namespace WidgetInstall {
std::string installInfo; ///<For recovery>
InstallLocationType locationType;
bool isUpdateMode;
+ InstallMode mode;
};
#endif // INSTALLER_CONTEXT_H
#include <job_base.h>
#include <job.h>
#include <widget_install/widget_install_errors.h>
+#include <wrt_install_mode.h>
#include <wrt_common_types.h>
#include <pkgmgr_signal_interface.h>
#include <memory>
ProgressPercent percent,
const ProgressDescription &);
-namespace InstallMode {
-enum Type
-{
- WRONG_INSTALL_MODE = -1,
- INSTALL_MODE_WGT,
- INSTALL_MODE_DIRECTORY,
- INSTALL_MODE_PRELOAD,
- REINSTALL_MODE_DIRECTORY
-};
-}
-
//TODO into namespace
//InstallationStruct
typedef Jobs::JobCallbacksBase<InstallerFinishedCallback,
//Widget Installation Struct
struct WidgetInstallationStruct : public WidgetInstallCallbackBase
{
- InstallMode::Type m_installMode;
+ InstallMode m_installMode;
std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface;
// It must be empty-constructible as a parameter of generic event
- WidgetInstallationStruct() :
- m_installMode(InstallMode::Type::INSTALL_MODE_WGT)
- {}
-
+ WidgetInstallationStruct() {};
WidgetInstallationStruct(
InstallerFinishedCallback finished,
InstallerProgressCallback progress,
void *param,
- InstallMode::Type mode,
+ InstallMode mode,
std::shared_ptr<PackageManager::IPkgmgrSignal>
_pkgmgrInterface
) :
WrtInstaller::WrtInstaller(int argc, char **argv) :
Application(argc, argv, "backend", false),
DPL::TaskDecl<WrtInstaller>(this),
- m_installMode(WRT_INSTALL_MODE_UNKNOWN),
m_packagePath(),
m_initialized(false),
m_numPluginsToInstall(0),
struct stat info;
if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) {
LogInfo("Installing package directly from directory");
- m_installMode = WRT_INSTALL_MODE_INSTALL_DIRECTORY;
+ m_installMode.extension = InstallMode::ExtensionType::DIR;
} else {
LogInfo("Installing from regular location");
- m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
+ m_installMode.extension = InstallMode::ExtensionType::WGT;
}
m_packagePath = m_argv[2];
return showHelpAndQuit();
}
m_packagePath = m_argv[2];
- m_installMode = WRT_INSTALL_MODE_INSTALL_PRELOAD;
+ m_installMode.installTime = InstallMode::InstallTime::PRELOAD;
AddStep(&WrtInstaller::installStep);
} else if (arg == "-c" || arg == "--csc-update") {
// "path=/opt/system/csc/Ozq2iEG15R-2.0.0-arm.wgt:op=install:removable=true"
if (it->second == CSCConfiguration::VALUE_INSTALL) {
LogDebug("operation = " << it->second);
- m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
+ m_installMode.extension = InstallMode::ExtensionType::WGT;
it = m_CSCconfigurationMap.find(CSCConfiguration::KEY_PATH);
if (it == m_CSCconfigurationMap.end()) {
return showHelpAndQuit();
return showHelpAndQuit();
}
LogInfo("Installing package directly from directory");
- m_installMode = WRT_INSTALL_MODE_REINSTALL;
+ m_installMode.command = InstallMode::Command::REINSTALL;
+ m_installMode.extension = InstallMode::ExtensionType::DIR;
m_packagePath = m_argv[2];
AddStep(&WrtInstaller::installStep);
} else {
struct stat info;
if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) {
LogInfo("Installing package directly from directory");
- m_installMode = WRT_INSTALL_MODE_INSTALL_DIRECTORY;
+ m_installMode.extension = InstallMode::ExtensionType::DIR;
} else {
LogInfo("Installing from regular location");
- m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
+ m_installMode.extension = InstallMode::ExtensionType::WGT;
}
AddStep(&WrtInstaller::installStep);
break;
break;
case PKGMGR_REQ_REINSTALL:
m_packagePath = m_argv[4];
- m_installMode = WRT_INSTALL_MODE_REINSTALL;
+ m_installMode.command = InstallMode::Command::REINSTALL;
+ m_installMode.extension = InstallMode::ExtensionType::DIR;
AddStep(&WrtInstaller::installStep);
break;
default:
void WrtInstaller::OnTerminate()
{
LogDebug("Wrt Shutdown now");
- PluginUtils::unlockPluginInstallation(m_installMode ==
- WRT_INSTALL_MODE_INSTALL_PRELOAD);
+ PluginUtils::unlockPluginInstallation(
+ m_installMode.installTime == InstallMode::InstallTime::PRELOAD);
if (m_initialized) {
wrt_installer_shutdown();
}
if (m_startupPluginInstallation) {
LogInfo("Plugin installation started because new plugin package found");
- } else if (!PluginUtils::lockPluginInstallation(m_installMode ==
- WRT_INSTALL_MODE_INSTALL_PRELOAD)) {
+ } else if (!PluginUtils::lockPluginInstallation(
+ m_installMode.installTime == InstallMode::InstallTime::PRELOAD))
+ {
LogError("Failed to open plugin installation lock file"
" Plugins are currently installed by other process");
staticWrtPluginInstallationCallback(WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED,
This->m_returnStatus = 0;
resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
- if (This->m_installMode == WRT_INSTALL_MODE_INSTALL_PRELOAD &&
- !This->m_packagePath.empty()) {
+ if (This->m_installMode.installTime == InstallMode::InstallTime::PRELOAD &&
+ !This->m_packagePath.empty())
+ {
LogDebug("This widget is preloaded so it will be removed : "
<< This->m_packagePath);
if (!WrtUtilRemove(This->m_packagePath)) {
}
//remove lock file
- if (!PluginUtils::unlockPluginInstallation(This->m_installMode ==
- WRT_INSTALL_MODE_INSTALL_PRELOAD)) {
+ if (!PluginUtils::unlockPluginInstallation(
+ This->m_installMode.installTime == InstallMode::InstallTime::PRELOAD))
+ {
LogInfo("Failed to remove installation lock");
}
{
LogDebug("Install new plugins");
- if (!PluginUtils::lockPluginInstallation(m_installMode ==
- WRT_INSTALL_MODE_INSTALL_PRELOAD)) {
+ if (!PluginUtils::lockPluginInstallation(
+ m_installMode.installTime == InstallMode::InstallTime::PRELOAD))
+ {
LogInfo("Lock NOT created");
return;
}
if (!PluginUtils::checkPluginInstallationRequired()) {
LogDebug("Plugin installation not required");
- PluginUtils::unlockPluginInstallation(m_installMode ==
- WRT_INSTALL_MODE_INSTALL_PRELOAD);
+ PluginUtils::unlockPluginInstallation(
+ m_installMode.installTime == InstallMode::InstallTime::PRELOAD);
return;
}
#include <string>
#include <map>
#include <wrt_installer_api.h>
+#include <wrt_install_mode.h>
namespace WRTInstallerNS { //anonymous
DECLARE_GENERIC_EVENT_0(QuitEvent)
// Private data
std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface;
- WrtInstallMode m_installMode;
+ InstallMode m_installMode;
std::string m_packagePath;
std::string m_name;
bool m_initialized;
#include <dpl/wrt-dao-ro/WrtDatabase.h>
#include <vcore/VCore.h>
#include <installer_main_thread.h>
+#include <wrt_install_mode.h>
using namespace WrtDB;
-#ifdef __cplusplus
-
-#define EXPORT_API __attribute__((visibility("default")))
-extern "C"
-{
-#endif
-inline InstallMode::Type translateInstallMode(
- WrtInstallMode installMode)
-{
- if (WRT_INSTALL_MODE_INSTALL_WGT == installMode) {
- return InstallMode::INSTALL_MODE_WGT;
- } else if (WRT_INSTALL_MODE_INSTALL_DIRECTORY == installMode) {
- return InstallMode::INSTALL_MODE_DIRECTORY;
- } else if (WRT_INSTALL_MODE_INSTALL_PRELOAD == installMode) {
- return InstallMode::INSTALL_MODE_PRELOAD;
- } else if (WRT_INSTALL_MODE_REINSTALL == installMode) {
- return InstallMode::REINSTALL_MODE_DIRECTORY;
- }
- Assert(true && "wrong argument is inputed");
- return InstallMode::WRONG_INSTALL_MODE;
-}
-
static std::string cutOffFileName(const std::string& path)
{
size_t found = path.find_last_of("/");
return if_ok;
}
-EXPORT_API void wrt_installer_init(void *userdata,
+void wrt_installer_init(void *userdata,
WrtInstallerInitCallback callback)
{
// Set DPL/LOG MID
return;
}
-EXPORT_API void wrt_installer_shutdown()
+void wrt_installer_shutdown()
{
try {
LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
}
}
-EXPORT_API void wrt_install_widget(
+void wrt_install_widget(
const char *path,
void* userdata,
WrtInstallerStatusCallback status_cb,
WrtProgressCallback progress_cb,
- WrtInstallMode installMode,
+ InstallMode installMode,
std::shared_ptr<PackageManager::
IPkgmgrSignal> pkgmgrInterface
)
{
UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
- if ( WRT_INSTALL_MODE_INSTALL_PRELOAD == installMode) {
+ if (InstallMode::InstallTime::PRELOAD == installMode.installTime) {
DPL::Log::OldStyleLogProvider *oldStyleProvider =
new DPL::Log::OldStyleLogProvider(false, false, false, true,
false, true);
InstallerCallbacksTranslate::installProgressCallback,
new InstallerCallbacksTranslate::StatusCallbackStruct(
userdata, status_cb, progress_cb),
- translateInstallMode(installMode),
+ installMode,
pkgmgrInterface)));
}
UNHANDLED_EXCEPTION_HANDLER_END
}
-EXPORT_API void wrt_uninstall_widget(
+void wrt_uninstall_widget(
const char * const tzAppid,
void* userdata,
WrtInstallerStatusCallback status_cb,
UNHANDLED_EXCEPTION_HANDLER_END
}
-EXPORT_API void wrt_install_plugin(
+void wrt_install_plugin(
const char *pluginDir,
void *user_param,
WrtPluginInstallerStatusCallback status_cb,
}
UNHANDLED_EXCEPTION_HANDLER_END
}
-
-#ifdef __cplusplus
-}
-#endif
#include <stdbool.h>
#include <stddef.h>
#include <wrt_type.h>
+#include <wrt_install_mode.h>
#include <pkgmgr_signal_interface.h>
#include <memory>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef void (*WrtInstallerInitCallback)(WrtErrStatus status,
void *data);
typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status,
const char *description,
void *data);
-enum WrtInstallMode
-{
- WRT_INSTALL_MODE_UNKNOWN = 0,
- WRT_INSTALL_MODE_INSTALL_WGT,
- WRT_INSTALL_MODE_INSTALL_DIRECTORY,
- WRT_INSTALL_MODE_INSTALL_PRELOAD,
- WRT_INSTALL_MODE_REINSTALL
-};
-
void wrt_installer_init(
void *userdata,
WrtInstallerInitCallback callback);
void *user_parameter,
WrtInstallerStatusCallback status_callback,
WrtProgressCallback progress_callback,
- WrtInstallMode install_mode,
+ InstallMode install_mode,
std::shared_ptr<PackageManager::IPkgmgrSignal>
pkgmgrInterface
);
WrtPluginInstallerStatusCallback statusCallback,
WrtProgressCallback progressCallback);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* WRT_INSTALLER_API_H_ */