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>
31 * @brief The WidgetLocation class
33 * Object that stores locations of several files/directories according
36 * Current package layout (of installed package) is following:
38 * /opt/apps/[package_name]
39 * \_____________ /data
40 * \_____________ /share
42 * \_____________ /bin/[id_of_installed_package]
43 * \_____________ /res/wgt/
45 * \___ [widgets_archive_content]
48 * Developer provides content of res/wgt directory (package contains that
51 * 2) For OSP Service Hybrid App is actually a bit different:
52 * Root is OSP Service directory, WebApp content is located in [root]/res/wgt
54 * Temporary directory is directory when widget is placed at the begining
55 * of installation process. After parsing process of config.xml, destination
56 * directory is created.
60 class DirectoryDeletor
64 DirectoryDeletor(std::string tempPath);
65 DirectoryDeletor(bool isPreload);
68 std::string getTempPath() const;
71 std::string m_dirpath;
75 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
76 DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
78 * @brief WidgetLocation
80 * Creates useless object. Needed by DPL::Optional
84 * @brief WidgetLocation Builds paths for widget location during
87 * Uninstallation process needs only installed package directory.
89 * @param widgetname name of widget
91 explicit WidgetLocation(const std::string & widgetname);
93 * @brief WidgetLocation Builds paths for widget location during
96 * @param widgetname name of widget
97 * @param sourcePath given source path
98 * @param t declaraced type of widget if type is needed
100 * In destruction removes temporary directory
102 WidgetLocation(const std::string & widgetname, std::string sourcePath,
103 WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
104 bool isReadonly = false);
106 WidgetLocation(const std::string & widgetname, std::string sourcePath,
108 WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
109 bool isReadonly = false);
114 std::string getInstallationDir() const; // /opt/apps or /usr/apps
115 std::string getPackageInstallationDir() const; // /opt/apps/[package]
116 std::string getSourceDir() const; // /opt/apps/[package]/res/wgt
117 std::string getBinaryDir() const; // /opt/apps/[package]/bin or /usr/apps/[package]/bin
118 std::string getUserBinaryDir() const; // /opt/apps/[package]/bin
119 std::string getExecFile() const; // /opt/apps/[package]/bin/[package]
120 std::string getBackupDir() const; // /opt/apps/[package].backup
121 std::string getBackupSourceDir() const; // /opt/apps/[pkg].backup/res/wgt
122 std::string getBackupBinaryDir() const; // /opt/apps/[pkg].backup/bin
123 std::string getBackupExecFile() const; // /opt/apps/[pkg].backup/bin/[pkg]
124 std::string getBackupPrivateDir() const; // /opt/apps/[pkg].backup/data
125 std::string getUserDataRootDir() const; // /opt/usr/apps/[package]
126 std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data
127 std::string getSharedRootDir() const; // /opt/usr/apps/[package]/shared
128 std::string getSharedResourceDir() const; // /opt/usr/apps/[package]/shared/res
129 std::string getSharedDataDir() const; // /opt/usr/apps/[package]/shared/data
130 std::string getSharedTrustedDir() const; // /opt/usr/apps/[package]/shared/trusted
131 std::string getBackupSharedDir() const; // /opt/usr/apps/[package].backup/shared
135 * @brief getTemporaryRootDir
136 * @return value of root for developer's provide package (root of unpacked
139 std::string getTemporaryPackageDir() const;
141 * @brief getTemporaryRootDir
143 * Value of this will differs according to type of installed widget.
145 * @return value of root for content in temporary directory to be copied
148 std::string getTemporaryRootDir() const;
150 * @brief getConfigurationDir Returns rott directory for configuration
153 * 1) For packed widgets it is just root of unpacked sources
154 * 2) For browser installation it is directory name of widget passed to
157 * @return configuration directory
159 std::string getConfigurationDir() const;
163 * @brief setIconTargetFilenameForLocale set installed ion path according to
165 * @param icon path of application icon
167 void setIconTargetFilenameForLocale(const std::string &icon);
170 * @brief getIconTargetFilename gets icon full path
171 * @param languageTag language tag
172 * @return value of full path
174 std::string getInstalledIconPath() const;
177 * @brief getWidgetSourcePath return widget's source path given to installer
178 * @return value of source path
180 std::string getWidgetSource() const;
182 * @brief pkgid Returns pkgid
185 DPL::String getPkgId() const;
189 * @brief registerExternalFile Registers file for database registration
192 * Registered file will be stored in database and removed automatically a
196 void registerExternalLocation(const std::string & file);
198 * @brief listExternalFile list all file to be registered
200 WrtDB::ExternalLocationList listExternalLocations() const;
205 void registerAppid(const std::string & appid);
208 std::string m_pkgid; //id of package
209 std::string m_widgetSource; // Source widget zip
211 std::string m_appid; //id of app
212 std::string m_iconPath; //installed icon path
213 WrtDB::PackagingType m_type;
214 std::shared_ptr<DirectoryDeletor> m_temp; //directory
215 WrtDB::ExternalLocationList m_externals;
216 std::string m_installedPath;
219 #endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H