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 optional type
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
138 std::string getBackupSharedDataDir() const; // /opt/usr/apps/[package].backup/shared/data
139 std::string getBackupSharedTrustedDir() const; // /opt/usr/apps/[package].backup/shared/trusted
140 std::string getNPPluginsDir() const; // /opt/usr/apps/[package]/res/wgt/plugins
141 std::string getNPPluginsExecFile() const; // /opt/usr/apps/[package]/bin/{execfile}
145 * @brief getTemporaryRootDir
146 * @return value of root for developer's provide package (root of unpacked
149 std::string getTemporaryPackageDir() const;
151 * @brief getTemporaryRootDir
153 * Value of this will differs according to type of installed widget.
155 * @return value of root for content in temporary directory to be copied
158 std::string getTemporaryRootDir() const;
162 * @brief setIconTargetFilenameForLocale set installed ion path according to
164 * @param icon path of application icon
166 void setIconTargetFilenameForLocale(const std::string &icon);
169 * @brief getIconTargetFilename gets icon full path
170 * @param languageTag language tag
171 * @return value of full path
173 std::string getInstalledIconPath() const;
176 * @brief getWidgetSourcePath return widget's source path given to installer
177 * @return value of source path
179 std::string getWidgetSource() const;
181 * @brief pkgid Returns pkgid
184 DPL::String getPkgId() const;
188 * @brief registerExternalFile Registers file for database registration
191 * Registered file will be stored in database and removed automatically a
195 void registerExternalLocation(const std::string & file);
197 * @brief listExternalFile list all file to be registered
199 WrtDB::ExternalLocationList listExternalLocations() const;
204 void registerAppid(const std::string & appid);
205 #ifdef SERVICE_ENABLED
206 void registerServiceAppid(const std::string & svcAppid);
210 std::string m_pkgid; // id of package
211 std::string m_widgetSource; // Source widget zip
213 std::string m_appid; // id of app
214 #ifdef SERVICE_ENABLED
215 std::string m_svcAppid;
217 std::string m_iconPath; // installed icon path
218 WrtDB::PackagingType m_type;
219 std::shared_ptr<DirectoryDeletor> m_temp; // directory
220 WrtDB::ExternalLocationList m_externals;
221 std::string m_installedPath;
222 InstallMode::ExtensionType m_extensionType;
225 #endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H