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.h
18 * @author Iwanek Tomasz (t.iwanek@smasung.com)
20 #ifndef WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
21 #define WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
26 #include <dpl/wrt-dao-ro/common_dao_types.h>
27 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
28 #include <wrt_common_types.h>
29 #include <wrt_install_mode.h>
32 * @brief The WidgetLocation class
34 * Object that stores locations of several files/directories according
37 * Current package layout (of installed package) is following:
39 * /opt/apps/[package_name]
40 * \_____________ /data
41 * \_____________ /share
43 * \_____________ /bin/[id_of_installed_package]
44 * \_____________ /res/wgt/
46 * \___ [widgets_archive_content]
49 * Developer provides content of res/wgt directory (package contains that
52 * 2) For OSP Service Hybrid App is actually a bit different:
53 * Root is OSP Service directory, WebApp content is located in [root]/res/wgt
55 * Temporary directory is directory when widget is placed at the begining
56 * of installation process. After parsing process of config.xml, destination
57 * directory is created.
61 class DirectoryDeletor
65 DirectoryDeletor(std::string tempPath);
66 DirectoryDeletor(bool isPreload);
69 std::string getTempPath() const;
72 std::string m_dirpath;
76 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
77 DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
79 * @brief WidgetLocation
81 * Creates useless object. Needed by DPL::Optional
85 * @brief WidgetLocation Builds paths for widget location during
88 * Uninstallation process needs only installed package directory.
90 * @param widgetname name of widget
92 explicit WidgetLocation(const std::string & widgetname);
94 * @brief WidgetLocation Builds paths for widget location during
97 * @param widgetname name of widget
98 * @param sourcePath given source path
99 * @param t declaraced type of widget if type is needed
101 * In destruction removes temporary directory
103 WidgetLocation(const std::string & widgetname, std::string sourcePath,
104 WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
105 bool isReadonly = false,
106 InstallMode::ExtensionType eType =
107 InstallMode::ExtensionType::WGT);
109 WidgetLocation(const std::string & widgetname, std::string sourcePath,
111 WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
112 bool isReadonly = false,
113 InstallMode::ExtensionType eType =
114 InstallMode::ExtensionType::WGT);
119 std::string getInstallationDir() const; // /opt/apps or /usr/apps
120 std::string getPackageInstallationDir() const; // /opt/apps/[package]
121 std::string getSourceDir() const; // /opt/apps/[package]/res/wgt
122 std::string getBinaryDir() const; // /opt/apps/[package]/bin or /usr/apps/[package]/bin
123 std::string getUserBinaryDir() const; // /opt/apps/[package]/bin
124 std::string getExecFile() const; // /opt/apps/[package]/bin/[package]
125 std::string getBackupDir() const; // /opt/apps/[package].backup
126 std::string getBackupSourceDir() const; // /opt/apps/[pkg].backup/res/wgt
127 std::string getBackupBinaryDir() const; // /opt/apps/[pkg].backup/bin
128 std::string getBackupExecFile() const; // /opt/apps/[pkg].backup/bin/[pkg]
129 std::string getBackupPrivateDir() const; // /opt/apps/[pkg].backup/data
130 std::string getUserDataRootDir() const; // /opt/usr/apps/[package]
131 std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data
132 std::string getPrivateTempStorageDir() const; // /opt/usr/apps/[package]/tmp
133 std::string getSharedRootDir() const; // /opt/usr/apps/[package]/shared
134 std::string getSharedResourceDir() const; // /opt/usr/apps/[package]/shared/res
135 std::string getSharedDataDir() const; // /opt/usr/apps/[package]/shared/data
136 std::string getSharedTrustedDir() const; // /opt/usr/apps/[package]/shared/trusted
137 std::string getBackupSharedDir() const; // /opt/usr/apps/[package].backup/shared
141 * @brief getTemporaryRootDir
142 * @return value of root for developer's provide package (root of unpacked
145 std::string getTemporaryPackageDir() const;
147 * @brief getTemporaryRootDir
149 * Value of this will differs according to type of installed widget.
151 * @return value of root for content in temporary directory to be copied
154 std::string getTemporaryRootDir() const;
156 * @brief getConfigurationDir Returns rott directory for configuration
159 * 1) For packed widgets it is just root of unpacked sources
160 * 2) For browser installation it is directory name of widget passed to
163 * @return configuration directory
165 std::string getConfigurationDir() const;
169 * @brief setIconTargetFilenameForLocale set installed ion path according to
171 * @param icon path of application icon
173 void setIconTargetFilenameForLocale(const std::string &icon);
176 * @brief getIconTargetFilename gets icon full path
177 * @param languageTag language tag
178 * @return value of full path
180 std::string getInstalledIconPath() const;
183 * @brief getWidgetSourcePath return widget's source path given to installer
184 * @return value of source path
186 std::string getWidgetSource() const;
188 * @brief pkgid Returns pkgid
191 DPL::String getPkgId() const;
195 * @brief registerExternalFile Registers file for database registration
198 * Registered file will be stored in database and removed automatically a
202 void registerExternalLocation(const std::string & file);
204 * @brief listExternalFile list all file to be registered
206 WrtDB::ExternalLocationList listExternalLocations() const;
211 void registerAppid(const std::string & appid);
214 std::string m_pkgid; //id of package
215 std::string m_widgetSource; // Source widget zip
217 std::string m_appid; //id of app
218 std::string m_iconPath; //installed icon path
219 WrtDB::PackagingType m_type;
220 std::shared_ptr<DirectoryDeletor> m_temp; //directory
221 WrtDB::ExternalLocationList m_externals;
222 std::string m_installedPath;
223 InstallMode::ExtensionType m_extensionType;
226 #endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H