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 task_widget_config.h
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief Implementation file for installer task widget config
22 #ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
23 #define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
29 #include <dpl/task_list.h>
30 #include <dpl/string.h>
31 #include <dpl/optional.h>
32 #include <dpl/wrt-dao-ro/config_parser_data.h>
33 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
34 #include <dpl/wrt-dao-ro/global_config.h>
36 #include <wrt_error.h>
37 #include <wrt_common_types.h>
38 #include <widget_install/widget_install_popup.h>
40 class InstallerContext;
43 namespace WidgetInstall {
44 namespace InstallerTaskWidgetPopupData {
47 DPL::String widgetInfo;
48 void addWidgetInfo(const DPL::String &info);
50 } // InstalllerTaskWidgetPopupData
52 class TaskWidgetConfig :
53 public DPL::TaskDecl<TaskWidgetConfig>,
54 public WidgetInstallPopup
60 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
61 DECLARE_EXCEPTION_TYPE(Base, ConfigParseFailed)
64 typedef std::list<std::pair<DPL::String, DPL::String> > StringPairList;
66 InstallerContext& m_installContext;
67 WrtDB::LocaleSet m_localeFolders;
68 std::set<DPL::String> m_processedIconSet;
69 InstallerTaskWidgetPopupData::PopupData m_popupData;
71 void StepProcessConfigurationFile();
72 void ReadLocaleFolders();
73 void ProcessLocalizedStartFiles();
74 void ProcessStartFile(const DPL::OptionalString& path,
75 const DPL::OptionalString& type,
76 const DPL::OptionalString& encoding = DPL::OptionalString::Null,
77 bool typeForcedInConfig = false);
78 void ProcessBackgroundPageFile();
79 void ProcessLocalizedIcons();
80 void ProcessIcon(const WrtDB::ConfigParserData::Icon& icon);
81 void StepVerifyFeatures();
82 void StepShowWidgetInfo();
83 void StepCheckMinVersionInfo();
85 template <typename Ex, const char* Msg>
86 void StepCancelInstallation();
88 void StepDeletePopupWin();
89 void StepCancelWidgetInstallationAfterVerifyFeatures();
90 void StepCancelWidgetInstallation();
91 void StepCancelWidgetInstallationAfterMinVersion();
92 void createInstallPopup(PopupType type, const std::string &label);
93 DPL::String createAuthorWidgetInfo() const;
94 void setApplicationType();
95 bool isFeatureAllowed(
96 WrtDB::AppType appType, DPL::String featureName);
97 bool isMinVersionCompatible(
98 WrtDB::AppType appType,
99 const DPL::OptionalString &widgetVersion) const;
101 * @brief Parses version string in format "major.minor.micro anything"
102 * Returns false if format is invalid
104 bool isTizenWebApp() const;
105 bool parseVersionString(const std::string &version, long &majorVersion,
106 long &minorVersion, long µVersion) const;
108 * This method is used to process the config.xml of widget, get
109 * the corresponding configuration to pWidgetConfigInfo
111 * @param[in] path Specified the widget archive file path (absolute path).
112 * @return Configuration information of widget
114 void processFile(const std::string& path,
115 WrtDB::WidgetRegisterInfo &wConfig);
117 bool locateAndParseConfigurationFile(const std::string& currentPath,
118 WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
119 const std::string& baseFolder,
121 bool parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
122 const std::string& _currentPath, int* pErrCode);
123 bool parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
124 const std::string& _currentPath, int* pErrCode);
125 bool fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
126 WrtDB::ConfigParserData& configInfo);
128 TaskWidgetConfig(InstallerContext& installTaskContext);
130 } //namespace WidgetInstall
133 #endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H