#include <dpl/log/log.h>
#include <dpl/sstream.h>
#include <dpl/localization/localization_utils.h>
-
#include <widget_install/task_commons.h>
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(bool isReadOnly) :
+ m_dirpath(Jobs::WidgetInstall::createTempPath(isReadOnly))
+{}
-WidgetLocation::DirectoryDeletor::DirectoryDeletor()
-{
- m_dirpath = Jobs::WidgetInstall::createTempPath();
-}
-
-WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath)
-{
- m_dirpath = tempPath;
-}
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
+ m_dirpath(tempPath)
+{}
WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
{
- LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
- if(!WrtUtilRemove(m_dirpath)){
- LogError("Fail at removing directory: " << m_dirpath.c_str());
+ LogDebug(
+ "Removing widget installation temporary directory: " << m_dirpath.c_str());
+ if (!WrtUtilRemove(m_dirpath)) {
+ LogWarning("Fail at removing directory: " << m_dirpath.c_str());
}
}
}
WidgetLocation::WidgetLocation()
-{
-}
+{}
WidgetLocation::WidgetLocation(const std::string & widgetname) :
- m_pkgid(widgetname)
-{
-}
+ m_pkgid(widgetname)
+{}
WidgetLocation::~WidgetLocation()
-{
-}
+{}
WidgetLocation::WidgetLocation(const std::string & widgetname,
std::string sourcePath,
WrtDB::PackagingType t,
- InstallLocationType locationType):
- m_pkgid(widgetname),
- m_widgetSource(sourcePath),
- m_type(t),
- m_temp(new WidgetLocation::DirectoryDeletor())
-{
- if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+ bool isReadonly) :
+ m_pkgid(widgetname),
+ m_widgetSource(sourcePath),
+ m_type(t),
+ m_temp(
+ new WidgetLocation::DirectoryDeletor(isReadonly))
+{
+ 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):
- m_pkgid(widgetname),
- m_widgetSource(sourcePath),
- m_type(t),
- m_temp(new
- WidgetLocation::DirectoryDeletor(dirPath))
-{
- if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+ bool isReadonly) :
+ m_pkgid(widgetname),
+ m_widgetSource(sourcePath),
+ m_type(t),
+ m_temp(new WidgetLocation::DirectoryDeletor(dirPath))
+{
+ 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
std::string WidgetLocation::getSourceDir() const
{
return m_installedPath + "/"
- + m_pkgid + WrtDB::GlobalConfig::GetWidgetSrcPath();
+ + m_pkgid + WrtDB::GlobalConfig::GetWidgetSrcPath();
}
std::string WidgetLocation::getBinaryDir() const
{
return m_installedPath + "/"
- + m_pkgid + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+ + m_pkgid + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+}
+
+std::string WidgetLocation::getUserBinaryDir() const
+{
+ return getUserDataRootDir() + "/"
+ + WrtDB::GlobalConfig::GetUserWidgetExecPath();
}
std::string WidgetLocation::getExecFile() const
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()) +
- "/" + m_pkgid;
+ "/" + m_pkgid;
}
std::string WidgetLocation::getPrivateStorageDir() const
{
return getUserDataRootDir() + "/" +
- WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
-}
-
-std::string WidgetLocation::getShareDir() const
-{
- return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
- + m_pkgid + "/" + WrtDB::GlobalConfig::GetWidgetSharePath();
+ WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
}
std::string WidgetLocation::getTemporaryPackageDir() const
std::string WidgetLocation::getTemporaryRootDir() const
{
if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
- return getWidgetSource();
+ return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
}
- if(m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP)
- {
+ if (m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP) {
return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
- }
- else
- {
+ } else {
return getTemporaryPackageDir();
}
}
std::string WidgetLocation::getConfigurationDir() const
{
- if(m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP)
- {
+ if (m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
std::string path = ".";
- int index = m_widgetSource.find_last_of("\\/");
- if (index != std::string::npos)
- {
+ std::size_t index = m_widgetSource.find_last_of("\\/");
+ if (index != std::string::npos) {
path = m_widgetSource.substr(0, index);
}
return path;
- }
- else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
- {
+ } else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
- } else
- {
+ } else {
return getTemporaryRootDir();
}
}