diff options
author | Taejeong Lee <taejeong.lee@samsung.com> | 2012-08-31 21:19:14 +0900 |
---|---|---|
committer | Taejeong Lee <taejeong.lee@samsung.com> | 2012-08-31 21:22:44 +0900 |
commit | 5ed3165dbb0d38b93fdfd6791d35815b02b9d365 (patch) | |
tree | 4924cb89d18cd5302a4e01b2f4e38010c848f3b3 /src/misc/widget_location.cpp | |
parent | 2ce76b65237f65d053c6e72c4a39dcaa38b83843 (diff) | |
download | wrt-installer-2.0alpha.tar.gz wrt-installer-2.0alpha.tar.bz2 wrt-installer-2.0alpha.zip |
Update wrt-installer_0.0.54HEADsubmit/master/20120920.1511542.0_alphamaster2.0alpha
Diffstat (limited to 'src/misc/widget_location.cpp')
-rw-r--r-- | src/misc/widget_location.cpp | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/src/misc/widget_location.cpp b/src/misc/widget_location.cpp new file mode 100644 index 0000000..3427433 --- /dev/null +++ b/src/misc/widget_location.cpp @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * @file widget_location.cpp + * @author Iwanek Tomasz (t.iwanek@smasung.com) + */ +#include "widget_location.h" + +#include <dpl/utils/wrt_utility.h> +#include <dpl/wrt-dao-ro/global_config.h> +#include <dpl/assert.h> +#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() +{ + LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str()); + _WrtUtilRemoveDir(m_dirpath.c_str()); +} + +std::string WidgetLocation::DirectoryDeletor::getTempPath() const +{ + return m_dirpath; +} + +WidgetLocation::WidgetLocation() : m_browser(false) +{ +} + +WidgetLocation::WidgetLocation(const std::string & widgetname) : m_pkgname(widgetname), m_browser(false) +{ +} + +WidgetLocation::~WidgetLocation() +{ +} + +WidgetLocation::WidgetLocation(const std::string & widgetname, + std::string sourcePath, + bool browserRequest, + WrtDB::PkgType t): + m_pkgname(widgetname), + m_widgetSource(sourcePath), + m_browser(browserRequest), + m_type(t), + m_temp(new WidgetLocation::DirectoryDeletor()) +{ +} + +std::string WidgetLocation::getInstallationDir() const +{ + return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()); +} + +std::string WidgetLocation::getPackageInstallationDir() const +{ + return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/" + + m_pkgname; +} + +std::string WidgetLocation::getSourceDir() const +{ + return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/" + + m_pkgname + "/" + WrtDB::GlobalConfig::GetWidgetSrcPath(); +} + +std::string WidgetLocation::getBinaryDir() const +{ + return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/" + + m_pkgname + "/" + WrtDB::GlobalConfig::GetUserWidgetExecPath(); +} + +std::string WidgetLocation::getBackupDir() const +{ + return getPackageInstallationDir() + "/backup"; +} + +std::string WidgetLocation::getTemporaryPackageDir() const +{ + return m_temp->getTempPath(); +} + +bool WidgetLocation::browserRequest() const +{ + return m_browser; +} + +std::string WidgetLocation::getTemporaryRootDir() const +{ + if(m_type == WrtDB::PKG_TYPE_TIZEN_WITHSVCAPP) + { + return getTemporaryPackageDir() + "/" + WrtDB::GlobalConfig::GetWidgetSrcPath(); + } + else + { + return getTemporaryPackageDir(); + } +} + +std::string WidgetLocation::getConfigurationDir() const +{ + if(m_browser) + { + std::string path = "."; + int index = m_widgetSource.find_last_of("\\/"); + if (index != std::string::npos) + { + path = m_widgetSource.substr(0, index); + } + return path; + } + else + { + return getTemporaryRootDir(); + } +} + +std::string WidgetLocation::getInstalledIconPath() const +{ + return m_iconPath; +} + +std::string WidgetLocation::getWidgetSource() const +{ + return m_widgetSource; +} + +void WidgetLocation::setIconTargetFilenameForLocale(const std::string & icon) +{ + m_iconPath = icon; +} |