Update wrt-installer_0.0.54
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_widget_config.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * @file    task_widget_config.h
18  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19  * @version 1.0
20  * @brief   Implementation file for installer task widget config
21  */
22 #ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
23 #define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H
24
25 #include <set>
26 #include <list>
27
28 #include <dpl/task.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>
35
36 #include <wrt_error.h>
37 #include <wrt_common_types.h>
38 #include <widget_install/widget_install_popup.h>
39
40 class InstallerContext;
41
42 namespace Jobs {
43 namespace WidgetInstall {
44 namespace InstallerTaskWidgetPopupData {
45 struct PopupData
46 {
47     DPL::String widgetInfo;
48     void addWidgetInfo(const DPL::String &info);
49 };
50 } // InstalllerTaskWidgetPopupData
51
52 class TaskWidgetConfig :
53     public DPL::TaskDecl<TaskWidgetConfig>,
54     public WidgetInstallPopup
55 {
56   private:
57     class Exception
58     {
59       public:
60         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
61         DECLARE_EXCEPTION_TYPE(Base, ConfigParseFailed)
62     };
63
64     typedef std::list<std::pair<DPL::String, DPL::String> > StringPairList;
65
66     InstallerContext& m_installContext;
67     WrtDB::LocaleSet m_localeFolders;
68     std::set<DPL::String> m_processedIconSet;
69     InstallerTaskWidgetPopupData::PopupData m_popupData;
70
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 ProcessLocalizedIcons();
79     void ProcessIcon(const WrtDB::ConfigParserData::Icon& icon);
80     void StepVerifyFeatures();
81     void StepShowWidgetInfo();
82     void StepCheckMinVersionInfo();
83
84     template <typename Ex, const char* Msg>
85     void StepCancelInstallation();
86
87     void StepDeletePopupWin();
88     void StepCancelWidgetInstallationAfterVerifyFeatures();
89     void StepCancelWidgetInstallation();
90     void StepCancelWidgetInstallationAfterMinVersion();
91     void createInstallPopup(PopupType type, const std::string &label);
92     DPL::String createAuthorWidgetInfo() const;
93     void setApplicationType();
94     bool isFeatureAllowed(
95             WrtDB::AppType appType, DPL::String featureName);
96     bool isMinVersionCompatible(
97             WrtDB::AppType appType,
98             const DPL::OptionalString &widgetVersion) const;
99     /**
100      * @brief Parses version string in format "major.minor.micro anything"
101      * Returns false if format is invalid
102      */
103     bool isTizenWebApp() const;
104     bool parseVersionString(const std::string &version, long &majorVersion,
105             long &minorVersion, long &microVersion) const;
106     /**
107      * This method is used to process the config.xml of widget, get
108      * the corresponding configuration to pWidgetConfigInfo
109      *
110      * @param[in] path Specified the widget archive file path (absolute path).
111      * @return         Configuration information of  widget
112      */
113     void processFile(const std::string& path,
114                      WrtDB::WidgetRegisterInfo &wConfig);
115
116     bool locateAndParseConfigurationFile(const std::string& currentPath,
117             WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
118             const std::string& baseFolder,
119             int* pErrCode);
120     bool parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
121                                     const std::string& _currentPath, int* pErrCode);
122     bool parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
123                                     const std::string& _currentPath, int* pErrCode);
124     bool fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
125                                     WrtDB::ConfigParserData& configInfo);
126   public:
127     TaskWidgetConfig(InstallerContext& installTaskContext);
128 };
129 } //namespace WidgetInstall
130 } //namespace Jobs
131
132 #endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_WIDGET_CONFIG_H