tizen 2.4 release
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_process_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_process_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_PROCESS_CONFIG_H
23 #define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PROCESS_CONFIG_H
24
25 #include <set>
26 #include <list>
27
28 #include <dpl/task.h>
29 #include <dpl/string.h>
30 #include <dpl/optional_typedefs.h>
31 #include <dpl/wrt-dao-ro/config_parser_data.h>
32 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
33 #include <dpl/wrt-dao-ro/global_config.h>
34
35 #include <widget_install/job_widget_install.h>
36 #include <wrt_common_types.h>
37
38 class InstallerContext;
39
40 namespace Jobs {
41 namespace WidgetInstall {
42
43 class TaskProcessConfig :
44     public DPL::TaskDecl<TaskProcessConfig>
45 {
46   private:
47     class Exception
48     {
49       public:
50         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
51         DECLARE_EXCEPTION_TYPE(Base, ConfigParseFailed)
52     };
53
54     typedef std::list<std::pair<DPL::String, DPL::String> > StringPairList;
55
56     JobWidgetInstall *m_jobContext;
57     WrtDB::LocaleSet m_localeFolders;
58     std::set<DPL::String> m_processedIconSet;
59     std::set<DPL::String> m_processedSmallIconSet;
60
61     void StepFillWidgetConfig();
62     void ReadLocaleFolders();
63     void ProcessLocalizedStartFiles();
64     void ProcessStartFile(
65         const DPL::OptionalString& path,
66         const DPL::OptionalString& type,
67         const DPL::OptionalString& encoding =
68             DPL::OptionalString(),
69         bool typeForcedInConfig = false);
70     void ProcessBackgroundPageFile();
71     void ProcessLocalizedIcons();
72     void ProcessIcon(const WrtDB::ConfigParserData::Icon& icon);
73     void ProcessWidgetInstalledPath();
74     void ProcessAppControlInfo();
75     void ProcessSecurityModel();
76     void StepVerifyFeatures();
77 #if USE(WEB_PROVIDER)
78     void StepVerifyLivebox();
79 #endif
80     void StepCheckMinVersionInfo();
81
82     template <typename Ex, const char* Msg>
83     void StepCancelInstallation();
84
85     void StartStep();
86     void EndStep();
87
88     DPL::String createAuthorWidgetInfo() const;
89     bool isFeatureAllowed(
90         WrtDB::AppType appType, DPL::String featureName);
91     bool isMinVersionCompatible(
92         WrtDB::AppType appType,
93         const DPL::OptionalString &widgetVersion) const;
94     /**
95      * @brief Parses version string in format "major.minor.micro anything"
96      * Returns false if format is invalid
97      */
98     bool isTizenWebApp() const;
99     bool parseVersionString(const std::string &version, long &majorVersion,
100                             long &minorVersion, long &microVersion) const;
101
102     bool fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
103                           WrtDB::ConfigParserData& configInfo);
104
105   public:
106     TaskProcessConfig(JobWidgetInstall * const &jobContext);
107 };
108 } //namespace WidgetInstall
109 } //namespace Jobs
110
111 #endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PROCESS_CONFIG_H