WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
{
LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
- WrtUtilRemove(m_dirpath);
+ if(!WrtUtilRemove(m_dirpath)){
+ LogError("Fail at removing directory: " << m_dirpath.c_str());
+ }
}
std::string WidgetLocation::DirectoryDeletor::getTempPath() const
WidgetLocation::WidgetLocation(const std::string & widgetname,
std::string sourcePath,
- WrtDB::PackagingType t):
+ WrtDB::PackagingType t,
+ InstallLocationType locationType):
m_pkgname(widgetname),
m_widgetSource(sourcePath),
m_type(t),
m_temp(new WidgetLocation::DirectoryDeletor())
{
+ if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+ m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
+ } else {
+ m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+ }
}
WidgetLocation::WidgetLocation(const std::string & widgetname,
std::string sourcePath,
std::string dirPath,
- WrtDB::PackagingType t):
+ WrtDB::PackagingType t,
+ InstallLocationType locationType):
m_pkgname(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 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();
}
return getBackupBinaryDir() + "/" + m_pkgname;
}
+std::string WidgetLocation::getUserDataRootDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +
+ "/" + m_pkgname;
+}
+
+std::string WidgetLocation::getPrivateStorageDir() const
+{
+ return getUserDataRootDir() + "/" +
+ WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
+}
+
+std::string WidgetLocation::getShareDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ + m_pkgname + "/" + WrtDB::GlobalConfig::GetWidgetSharePath();
+}
+
std::string WidgetLocation::getTemporaryPackageDir() const
{
return m_temp->getTempPath();
std::string WidgetLocation::getTemporaryRootDir() const
{
+ if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
+ return getWidgetSource();
+ }
if(m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP)
{
return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
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("\\/");
}
return path;
}
- else
+ else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+ {
+ return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
+ } else
{
return getTemporaryRootDir();
}