for list in $_wgt_list
do
echo "Install $list"
- return_string=`wrt-installer -i $list`
+ return_string=`wrt-installer -il $list`
if [ "$return_string" != "${return_string/installed/}" ]; then
echo "$list widget installation success"
rm -rf $list
}
return (0 == filename.compare(fileLen-extLen, extLen, extension));
}
+
+bool checkTizenIdExist(const std::string& tizenId) {
+ std::string installPath =
+ std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
+ "/" + tizenId;
+ std::string preinstallPath =
+ std::string(GlobalConfig::GetUserPreloadedWidgetPath()) +
+ "/" + tizenId;
+
+ struct stat dirStat;
+ if ((stat(installPath.c_str(), &dirStat) == 0) &&
+ (stat(preinstallPath.c_str(), &dirStat) == 0)) {
+ return true;
+ }
+ return false;
+}
} // namespace anonymous
namespace Jobs {
Try
{
- std::string tempDir = Jobs::WidgetInstall::createTempPath();
+ std::string tempDir =
+ Jobs::WidgetInstall::createTempPath(m_jobStruct.m_preload);
m_isDRM = isDRMWidget(widgetPath);
if (true == m_isDRM) {
}
bool JobWidgetInstall::setTizenId(
- const WrtDB::ConfigParserData &configInfo, ConfigureResult result)
+ const WrtDB::ConfigParserData &configInfo, ConfigureResult result,
+ bool preload)
{
regex_t reg;
if(regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
}
struct stat dirStat;
+
if(!!configInfo.tizenId) {
LogDebug("Setting tizenId provided in config.xml: " << configInfo.tizenId);
if ((regexec(®, DPL::ToUTF8String(*(configInfo.tizenId)).c_str(),
static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
- ((stat((std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/"
- + DPL::ToUTF8String(*(configInfo.tizenId))).c_str(), &dirStat) == 0)
- && result != ConfigureResult::Updated))
+ (checkTizenIdExist(DPL::ToUTF8String(*(configInfo.tizenId))) &&
+ result != ConfigureResult::Updated))
{
//it is true when tizenId does not fit REG_TIZENID_PATTERN
LogError("tizen_id provided but not proper.");
// only for installation, not for update
if (result == ConfigureResult::Ok) {
//check if there is package with same name and if generate different name
- std::string path = GlobalConfig::GetUserInstalledWidgetPath();
- path += "/";
-
- std::ostringstream newPath;
- newPath << path << tizenId;
LogDebug("Checking if tizen id is unique");
while (true) {
- if (stat(newPath.str().c_str(), &dirStat) == 0) {
+ if (checkTizenIdExist(DPL::ToUTF8String(tizenId))) {
//path exist, chose another one
tizenId = WidgetDAOReadOnly::generateTizenId();
- newPath.str("");
- newPath << path << tizenId;
continue;
}
break;
m_installerContext.locations =
WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
widgetPath, tempPath,
- m_installerContext.widgetConfig.packagingType);
+ m_installerContext.widgetConfig.packagingType,
+ m_jobStruct.m_preload);
LogInfo("widgetSource " << widgetPath);
}
return ConfigureResult::Failed;
}
- if (!setTizenId(configData, ret)) {
+ if (!setTizenId(configData, ret, m_jobStruct.m_preload)) {
return ConfigureResult::Failed;
} else {
using namespace PackageManager;
const OptionalWidgetVersion &existingVersion,
const OptionalWidgetVersion &incomingVersion) const;
bool setTizenId(const WrtDB::ConfigParserData &configInfo,
- ConfigureResult result);
+ ConfigureResult result,
+ bool preload);
void displayWidgetInfo();
void configureWidgetLocation(const std::string & widgetPath,
const std::string &tempPath);
} // namespace
-std::string createTempPath()
+std::string createTempPath(bool preload)
{
LogInfo("Step: Creating temporary path");
// Temporary path
std::ostringstream tempPathBuilder;
- tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+ //tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+ if (preload) {
+ tempPathBuilder << WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
+ } else {
+ tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+ }
+ tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
tempPathBuilder << "/";
tempPathBuilder << TEMPORARY_PATH_POSTFIX;
tempPathBuilder << "_";
//TODO make directory like jobs common?
-std::string createTempPath();
+std::string createTempPath(bool preload = false);
+std::string createTempPath(bool preload);
void createTempPath(const std::string& path);
WrtUtilMakeDir(widgetPath);
+ if (m_context.job->getInstallerStruct().m_preload) {
+ std::string privateDir = m_context.locations->getBasePrivateDir();
+ WrtUtilMakeDir(privateDir);
+ }
+
// If package type is widget with osp service, we don't need to make bin
// and src directory
if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
m_context.installStep =
InstallerContext::INSTALL_CREATE_PRIVATE_STORAGE;
- std::ostringstream widgetPath;
+ std::ostringstream widgetDataPath;
DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
if(!pkgname.IsNull()) {
- widgetPath << m_context.locations->getPackageInstallationDir() << "/";
+ widgetDataPath << m_context.locations->getBasePrivateDir() << "/";
} else {
ThrowMsg(Exceptions::InternalError, "No Package name exists.");
}
- if (euidaccess(widgetPath.str().c_str(), W_OK | X_OK) != 0) {
+ if (euidaccess(widgetDataPath.str().c_str(), W_OK | X_OK) != 0) {
ThrowMsg(Exceptions::InternalError, DPL::GetErrnoString());
}
std::ostringstream storagePath;
- storagePath << widgetPath.str().c_str()
+ storagePath << widgetDataPath.str().c_str()
<< GlobalConfig::GetWidgetPrivateStoragePath();
if (euidaccess(storagePath.str().c_str(), F_OK) != 0) {
AddStep(&TaskWidgetConfig::ProcessLocalizedStartFiles);
AddStep(&TaskWidgetConfig::ProcessBackgroundPageFile);
AddStep(&TaskWidgetConfig::ProcessLocalizedIcons);
+ AddStep(&TaskWidgetConfig::ProcessWidgetInstalledPath);
AddStep(&TaskWidgetConfig::StepVerifyFeatures);
AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
}
}
+void TaskWidgetConfig::ProcessWidgetInstalledPath()
+{
+ LogDebug("ProcessWidgetInstalledPath");
+ m_installContext.widgetConfig.widgetInstalledPath =
+ DPL::FromUTF8String(m_installContext.locations->getPackageInstallationDir());
+}
+
void TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures()
{
LogDebug("StepCancelWidgetInstallationAfterVerifyFeatures");
void ProcessBackgroundPageFile();
void ProcessLocalizedIcons();
void ProcessIcon(const WrtDB::ConfigParserData::Icon& icon);
+ void ProcessWidgetInstalledPath();
void StepVerifyFeatures();
void StepShowWidgetInfo();
void StepCheckMinVersionInfo();
{
WidgetUpdateMode::Type updateMode;
bool m_quiet;
+ bool m_preload;
// It must be empty-constructible as a parameter of generic event
WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
- m_quiet(true)
+ m_quiet(true),
+ m_preload(false)
{
}
InstallerProgressCallback progress,
void *param,
WidgetUpdateMode::Type mode,
- bool quiet) :
+ bool quiet,
+ bool preload) :
WidgetInstallCallbackBase(finished, progress, param),
updateMode(mode),
- m_quiet(quiet)
+ m_quiet(quiet),
+ m_preload(preload)
{
}
};
if(!WrtUtilRemove(widgetDir)){
LogWarning("Removing widget installation directory failed");
}
+ std::string dataDir = m_context.locations->getBasePrivateDir();
+ if(!WrtUtilRemove(dataDir)){
+ LogWarning(dataDir + " is already removed");
+ }
m_context.job->UpdateProgress(
UninstallerContext::UNINSTALL_REMOVE_WIDGETDIR,
"Widget INstallation Directory Removal Finished");
LogDebug(" -> " << *path);
int ret = remove(path->c_str());
if (ret != 0) {
- LogDebug("Failed to remove the file: " << path->c_str() << " with error: " << strerror(errno));
+ LogError("Failed to remove the file: " << path->c_str() << " with error: " << strerror(errno));
}
}
else if(WrtUtilDirExists(*path))
{
LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
if(!WrtUtilRemove(m_dirpath)){
- LogDebug("Fail at removing directory: " << m_dirpath.c_str());
+ LogError("Fail at removing directory: " << m_dirpath.c_str());
}
}
WidgetLocation::WidgetLocation(const std::string & widgetname,
std::string sourcePath,
- WrtDB::PackagingType t):
+ WrtDB::PackagingType t,
+ bool preload):
m_pkgname(widgetname),
m_widgetSource(sourcePath),
m_type(t),
m_temp(new WidgetLocation::DirectoryDeletor())
{
+ if (preload) {
+ m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+ } else {
+ m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
+ }
}
WidgetLocation::WidgetLocation(const std::string & widgetname,
std::string sourcePath,
std::string dirPath,
- WrtDB::PackagingType t):
+ WrtDB::PackagingType t,
+ bool preload):
m_pkgname(widgetname),
m_widgetSource(sourcePath),
m_type(t),
m_temp(new
WidgetLocation::DirectoryDeletor(dirPath))
{
+ if (preload) {
+ m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
+ } else {
+ m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+ }
}
// TODO cache all these paths
std::string WidgetLocation::getInstallationDir() const
{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath());
+ return m_installedPath;
}
std::string WidgetLocation::getPackageInstallationDir() const
{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
- + m_pkgname;
+ return m_installedPath + "/" + m_pkgname;
}
std::string WidgetLocation::getSourceDir() const
{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ return m_installedPath + "/"
+ m_pkgname + WrtDB::GlobalConfig::GetWidgetSrcPath();
}
std::string WidgetLocation::getBinaryDir() const
{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ return m_installedPath + "/"
+ m_pkgname + WrtDB::GlobalConfig::GetUserWidgetExecPath();
}
m_externals.push_back(file);
}
+std::string WidgetLocation::getBasePrivateDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +
+ "/" + m_pkgname;
+}
+
WrtDB::ExternalLocationList WidgetLocation::listExternalLocations() const
{
return m_externals;
* In destruction removes temporary directory
*/
WidgetLocation(const std::string & widgetname, std::string sourcePath,
- WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP);
+ WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
+ bool preload = false);
WidgetLocation(const std::string & widgetname, std::string sourcePath,
std::string dirPath,
- WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP);
+ WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
+ bool preload = false);
+
~WidgetLocation();
// Installed paths
- std::string getInstallationDir() const; // /opt/apps
+ std::string getInstallationDir() const; // /opt/apps or /usr/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 getBackupSourceDir() const; // /opt/apps/[package]/backup/res/wgt
std::string getBackupBinaryDir() const; // /opt/apps/[package]/backup/bin
std::string getBackupExecFile() const; // /opt/apps/[package]/backup/bin/[package]
+ std::string getBasePrivateDir() const; // /opt/apps
// Temporary paths
/**
WrtDB::PackagingType m_type;
std::shared_ptr<DirectoryDeletor> m_temp; //directory
WrtDB::ExternalLocationList m_externals;
+ std::string m_installedPath;
};
#endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
m_installByPkgmgr(false),
m_quiet(true),
m_popup(NULL),
- m_startupPluginInstallation(false)
+ m_startupPluginInstallation(false),
+ m_preloadWidget(false)
{
Touch();
LogDebug("App Created");
m_packagePath = m_argv[2];
m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
AddStep(&WrtInstaller::installStep);
+ } else if (arg == "-il" || arg == "--install-preload") {
+ if (m_argc != 3) {
+ return showHelpAndQuit();
+ }
+
+ m_packagePath = m_argv[2];
+ m_preloadWidget = true;
+ m_installPolicy = WRT_WIM_POLICY_WAC;
+ AddStep(&WrtInstaller::installStep);
} else if (arg == "-un" || arg == "--uninstall-name") {
if (m_argc != 3) {
return showHelpAndQuit();
(!m_quiet || m_installByPkgmgr)
? &staticWrtInstallProgressCallback : NULL,
m_installPolicy,
- m_quiet);
+ m_quiet,
+ m_preloadWidget);
}
void WrtInstaller::installPluginsStep()
bool m_startupPluginInstallation;
std::string m_webAppConfig;
std::string m_webAppIcon;
+ bool m_preloadWidget;
typedef std::list<std::string> PluginPathList;
DPL::Optional<PluginPathList> m_pluginsPaths;
"Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
"> does not exist.");
}
+
+ if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath()));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetUserPreloadedWidgetPath() <<
+ "> does not exist.");
+ }
return if_ok;
}
WrtInstallerStatusCallback status_cb,
WrtProgressCallback progress_cb,
wrt_widget_update_mode_t update_mode,
- bool quiet)
+ bool quiet,
+ bool preload)
{
UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
new InstallerCallbacksTranslate::StatusCallbackStruct(
userdata, status_cb, progress_cb),
translateWidgetUpdateMode(update_mode),
- quiet)));
+ quiet,
+ preload)));
}
UNHANDLED_EXCEPTION_HANDLER_END
}
* void *user_parameter,
* WrtInstallerStatusCallback status_callback,
* WrtProgressCallback progress_callback,
- * wrt_widget_update_mode_t update_mode);
+ * wrt_widget_update_mode_t update_mode,
+ * bool quiet,
+ * bool preload);
*
* @brief Installs widget from given path
*
* If you don't want to get progress data, this
* should be NULL
* @param [in] install_mode Installation mode
+ * @param [in] quiet quiet mode
+ * @param [in] preload preload widget install
* @return Nothing (status returned in callback).
*
* Sample code:
* NULL,
* install_cb,
* progress_cb,
- * WRT_WIM_POLICY_WAC);
+ * WRT_WIM_POLICY_WAC,
+ * false,
+ * false);
* @endcode
*
* @see wrt_installer_uninstall_widget
WrtInstallerStatusCallback status_callback,
WrtProgressCallback progress_callback,
wrt_widget_update_mode_t update_mode,
- bool quiet);
+ bool quiet,
+ bool preload);
/**
* @fn void wrt_installer_uninstall_widget (const char * const pkg_name,