2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file widget_location.cpp
18 * @author Iwanek Tomasz (t.iwanek@smasung.com)
20 #include "widget_location.h"
22 #include <dpl/utils/wrt_utility.h>
23 #include <dpl/wrt-dao-ro/global_config.h>
24 #include <dpl/assert.h>
25 #include <dpl/log/log.h>
26 #include <dpl/sstream.h>
27 #include <dpl/localization/localization_utils.h>
29 #include <widget_install/task_commons.h>
32 WidgetLocation::DirectoryDeletor::DirectoryDeletor()
34 m_dirpath = Jobs::WidgetInstall::createTempPath();
37 WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
39 LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
40 _WrtUtilRemoveDir(m_dirpath.c_str());
43 std::string WidgetLocation::DirectoryDeletor::getTempPath() const
48 WidgetLocation::WidgetLocation() : m_browser(false)
52 WidgetLocation::WidgetLocation(const std::string & widgetname) : m_pkgname(widgetname), m_browser(false)
56 WidgetLocation::~WidgetLocation()
60 WidgetLocation::WidgetLocation(const std::string & widgetname,
61 std::string sourcePath,
64 m_pkgname(widgetname),
65 m_widgetSource(sourcePath),
66 m_browser(browserRequest),
68 m_temp(new WidgetLocation::DirectoryDeletor())
72 std::string WidgetLocation::getInstallationDir() const
74 return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath());
77 std::string WidgetLocation::getPackageInstallationDir() const
79 return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
83 std::string WidgetLocation::getSourceDir() const
85 return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
86 + m_pkgname + "/" + WrtDB::GlobalConfig::GetWidgetSrcPath();
89 std::string WidgetLocation::getBinaryDir() const
91 return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
92 + m_pkgname + "/" + WrtDB::GlobalConfig::GetUserWidgetExecPath();
95 std::string WidgetLocation::getBackupDir() const
97 return getPackageInstallationDir() + "/backup";
100 std::string WidgetLocation::getTemporaryPackageDir() const
102 return m_temp->getTempPath();
105 bool WidgetLocation::browserRequest() const
110 std::string WidgetLocation::getTemporaryRootDir() const
112 if(m_type == WrtDB::PKG_TYPE_TIZEN_WITHSVCAPP)
114 return getTemporaryPackageDir() + "/" + WrtDB::GlobalConfig::GetWidgetSrcPath();
118 return getTemporaryPackageDir();
122 std::string WidgetLocation::getConfigurationDir() const
126 std::string path = ".";
127 int index = m_widgetSource.find_last_of("\\/");
128 if (index != std::string::npos)
130 path = m_widgetSource.substr(0, index);
136 return getTemporaryRootDir();
140 std::string WidgetLocation::getInstalledIconPath() const
145 std::string WidgetLocation::getWidgetSource() const
147 return m_widgetSource;
150 void WidgetLocation::setIconTargetFilenameForLocale(const std::string & icon)