#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(bool isReadOnly) :
+ m_dirpath(Jobs::WidgetInstall::createTempPath(isReadOnly))
{}
WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
LogDebug(
"Removing widget installation temporary directory: " << m_dirpath.c_str());
if (!WrtUtilRemove(m_dirpath)) {
- LogError("Fail at removing directory: " << m_dirpath.c_str());
+ LogWarning("Fail at removing directory: " << m_dirpath.c_str());
}
}
WidgetLocation::WidgetLocation(const std::string & widgetname,
std::string sourcePath,
WrtDB::PackagingType t,
- InstallLocationType locationType) :
+ bool isReadonly) :
m_pkgid(widgetname),
m_widgetSource(sourcePath),
m_type(t),
- m_temp(new WidgetLocation::DirectoryDeletor())
+ m_temp(
+ new WidgetLocation::DirectoryDeletor(isReadonly))
{
- if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+ if (isReadonly) {
m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
} else {
m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
}
+ // TODO clean-up
+ if (access(m_widgetSource.c_str(), F_OK) != 0) {
+ m_widgetSource = m_installedPath + "/" + m_pkgid;
+ }
}
WidgetLocation::WidgetLocation(const std::string & widgetname,
std::string sourcePath,
std::string dirPath,
WrtDB::PackagingType t,
- InstallLocationType locationType) :
+ bool isReadonly) :
m_pkgid(widgetname),
m_widgetSource(sourcePath),
m_type(t),
- m_temp(new
- WidgetLocation::DirectoryDeletor(dirPath))
+ m_temp(new WidgetLocation::DirectoryDeletor(dirPath))
{
- if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+ if (isReadonly) {
m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
} else {
m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
}
+ // TODO clean-up
+ if (access(m_widgetSource.c_str(), F_OK) != 0) {
+ m_widgetSource = m_installedPath + "/" + m_pkgid;
+ }
}
// TODO cache all these paths
+ m_pkgid + WrtDB::GlobalConfig::GetUserWidgetExecPath();
}
+std::string WidgetLocation::getUserBinaryDir() const
+{
+ return getUserDataRootDir() + "/"
+ + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+}
+
std::string WidgetLocation::getExecFile() const
{
return getBinaryDir() + "/" + m_appid;
std::string WidgetLocation::getBackupDir() const
{
- return getPackageInstallationDir() + "/backup";
+ return getPackageInstallationDir() + ".backup";
}
std::string WidgetLocation::getBackupSourceDir() const
return getBackupBinaryDir() + "/" + m_appid;
}
+std::string WidgetLocation::getBackupPrivateDir() const
+{
+ return getBackupDir() + "/" +
+ WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
+}
+
std::string WidgetLocation::getUserDataRootDir() const
{
return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +