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>
30 * @brief The WidgetLocation class
32 * Object that stores locations of several files/directories according
35 * Current package layout (of installed package) is following:
37 * /opt/apps/[package_name]
38 * \_____________ /data
40 * \_____________ /bin/[id_of_installed_package]
41 * \_____________ /res/wgt/
43 * \___ [widgets_archive_content]
46 * Developer provides content of res/wgt directory (package contains that directory as root).
48 * 2) For OSP Service Hybrid App is actually a bit different:
49 * Root is OSP Service directory, WebApp content is located in [root]/res/wgt
51 * Temporary directory is directory when widget is placed at the begining
52 * of installation process. After parsing process of config.xml, destination directory is created.
56 class DirectoryDeletor
60 DirectoryDeletor(std::string tempPath);
62 std::string getTempPath() const;
64 std::string m_dirpath;
68 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
69 DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
71 * @brief WidgetLocation
73 * Creates useless object. Needed by DPL::Optional
77 * @brief WidgetLocation Builds paths for widget location during uninstallation
79 * Uninstallation process needs only installed package directory.
81 * @param widgetname name of widget
83 WidgetLocation(const std::string & widgetname);
85 * @brief WidgetLocation Builds paths for widget location during installation
87 * @param widgetname name of widget
88 * @param sourcePath given source path
89 * @param t declaraced type of widget if type is needed
91 * In destruction removes temporary directory
93 WidgetLocation(const std::string & widgetname, std::string sourcePath,
94 WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP);
96 WidgetLocation(const std::string & widgetname, std::string sourcePath,
98 WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP);
102 std::string getInstallationDir() const; // /opt/apps
103 std::string getPackageInstallationDir() const; // /opt/apps/[package]
104 std::string getSourceDir() const; // /opt/apps/[package]/res/wgt
105 std::string getBinaryDir() const; // /opt/apps/[package]/bin
106 std::string getExecFile() const; // /opt/apps/[package]/bin/[package]
107 std::string getBackupDir() const; // /opt/apps/[package]/backup
108 std::string getBackupSourceDir() const; // /opt/apps/[package]/backup/res/wgt
109 std::string getBackupBinaryDir() const; // /opt/apps/[package]/backup/bin
110 std::string getBackupExecFile() const; // /opt/apps/[package]/backup/bin/[package]
114 * @brief getTemporaryRootDir
115 * @return value of root for developer's provide package (root of unpacked .wgt file)
117 std::string getTemporaryPackageDir() const;
119 * @brief getTemporaryRootDir
121 * Value of this will differs according to type of installed widget.
123 * @return value of root for content in temporary directory to be copied into 'res/wgt'
125 std::string getTemporaryRootDir() const;
127 * @brief getConfigurationDir Returns rott directory for configuration requirements
129 * 1) For packed widgets it is just root of unpacked sources
130 * 2) For browser installation it is directory name of widget passed to installer
132 * @return configuration directory
134 std::string getConfigurationDir() const;
138 * @brief setIconTargetFilenameForLocale set installed ion path according to locale
139 * @param icon path of application icon
141 void setIconTargetFilenameForLocale(const std::string &icon);
143 * @brief getIconTargetFilename gets icon path suffix for locale
144 * @param languageTag language tag
145 * @return value of suffix of path
147 DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
149 * @brief getIconTargetFilename gets icon full path
150 * @param languageTag language tag
151 * @return value of full path
153 std::string getInstalledIconPath() const;
156 * @brief getWidgetSourcePath return widget's source path given to installer
157 * @return value of source path
159 std::string getWidgetSource() const;
161 * @brief pkgname Returns pkgname
164 DPL::String getPkgname() const;
168 * @brief registerExternalFile Registers file for database registration
171 * Registered file will be stored in database and removed automatically a
175 void registerExternalLocation(const std::string & file);
177 * @brief listExternalFile list all file to be registered
179 WrtDB::ExternalLocationList listExternalLocations() const;
182 std::string m_widgetSource; // Source widget zip file/widget url
183 std::string m_pkgname; //name of package
184 std::string m_iconPath; //installed icon path
185 WrtDB::PackagingType m_type;
186 std::shared_ptr<DirectoryDeletor> m_temp; //directory
187 WrtDB::ExternalLocationList m_externals;
190 #endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H