#include <widget_install/task_commons.h>
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(bool isPreload) :
+ m_dirpath(Jobs::WidgetInstall::createTempPath(isPreload))
+{}
-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)){
+ LogDebug(
+ "Removing widget installation temporary directory: " << m_dirpath.c_str());
+ if (!WrtUtilRemove(m_dirpath)) {
LogError("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())
+ InstallLocationType locationType) :
+ m_pkgid(widgetname),
+ m_widgetSource(sourcePath),
+ m_type(t),
+ m_temp(
+ new WidgetLocation::DirectoryDeletor(
+ INSTALL_LOCATION_TYPE_PRELOAD == locationType))
{
if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
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))
+ InstallLocationType locationType) :
+ m_pkgid(widgetname),
+ m_widgetSource(sourcePath),
+ m_type(t),
+ m_temp(new
+ WidgetLocation::DirectoryDeletor(dirPath))
{
if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
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::getExecFile() const
{
- return getBinaryDir() + "/" + m_pkgid;
+ return getBinaryDir() + "/" + m_appid;
}
std::string WidgetLocation::getBackupDir() const
std::string WidgetLocation::getBackupExecFile() const
{
- return getBackupBinaryDir() + "/" + m_pkgid;
+ return getBackupBinaryDir() + "/" + m_appid;
}
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();
}
}
{
return m_externals;
}
+
+void WidgetLocation::registerAppid(const std::string & appid)
+{
+ m_appid = appid;
+}