Source code formating unification
[framework/web/wrt-installer.git] / src / jobs / widget_install / job_widget_install.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    job_widget_install.h
18  * @author  Radoslaw Wicik r.wicik@samsung.com
19  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20  * @version 1.0
21  * @brief   Implementation file for main installer task
22  */
23 #ifndef WRT_SRC_INSTALLER_CORE_JOB_JOB_WIDGET_INSTALL_H_
24 #define WRT_SRC_INSTALLER_CORE_JOB_JOB_WIDGET_INSTALL_H_
25
26 #include <dpl/optional.h>
27 #include <dpl/string.h>
28 #include <job.h>
29 #include <job_base.h>
30 #include <dpl/utils/widget_version.h>
31 #include <widget_install/widget_install_context.h>
32 #include <widget_install/widget_update_info.h>
33 #include <dpl/wrt-dao-ro/config_parser_data.h>
34 #include "widget_installer_struct.h"
35
36 namespace Jobs {
37 namespace WidgetInstall {
38 class JobWidgetInstall :
39     public Job,
40     public JobProgressBase<InstallerContext::InstallStep,
41                            InstallerContext::INSTALL_END>,
42     public JobContextBase<WidgetInstallationStruct>   //TODO typedef
43 {
44   private:
45     InstallerContext m_installerContext;
46
47     //TODO move it to base class of all jobs -> make it base template class??
48     Exceptions::Type m_exceptionCaught;
49     std::string m_exceptionMessage;
50     WidgetUpdateInfo m_widgetUpdateInfo;
51     bool m_needEncryption;
52     bool m_isDRM;
53
54     enum class ConfigureResult
55     {
56         Ok, Failed, Deferred, Updated
57     };
58
59     ConfigureResult ConfigureInstallation(const std::string &widgetSource,
60                                           const WrtDB::ConfigParserData
61                                           &configData,
62                                           const std::string &tempPath);
63     static WrtDB::ConfigParserData getWidgetDataFromXML(
64         const std::string &widgetSource,
65         const std::string &tempPath,
66         WrtDB::PackagingType pkgType,
67         bool isDRM);
68     static WidgetUpdateInfo detectWidgetUpdate(
69         const WrtDB::ConfigParserData &configInfo,
70         const WrtDB::WidgetType appType,
71         const WrtDB::TizenAppId &tizenId);
72     WidgetUpdateMode::Type CalcWidgetUpdatePolicy(
73         const OptionalWidgetVersion &existingVersion,
74         const OptionalWidgetVersion &incomingVersion) const;
75     void setTizenId(const WrtDB::ConfigParserData &configInfo);
76     void displayWidgetInfo();
77     void configureWidgetLocation(const std::string & widgetPath,
78                                  const std::string &tempPath);
79
80     WrtDB::PackagingType checkPackageType(
81         const std::string &widgetSource,
82         const std::string &tempPath);
83     bool detectResourceEncryption(const WrtDB::ConfigParserData &configData);
84     void setInstallLocationType(const WrtDB::ConfigParserData
85                                 &configData);
86     bool isDRMWidget(std::string widgetPath);
87     bool DecryptDRMWidget(std::string widgetPath, std::string destPath);
88     ConfigureResult PrePareInstallation(const std::string &widgetPath);
89     ConfigureResult checkWidgetUpdate(const WidgetUpdateInfo &update);
90     void setApplicationType(const WrtDB::ConfigParserData &configInfo);
91
92   public:
93     /**
94      * @brief Automaticaly sets installation process
95      */
96     JobWidgetInstall(std::string const & widgetPath,
97                      const WidgetInstallationStruct &installerStruct);
98
99     //overrides
100     void SendProgress();
101     void SendFinishedSuccess();
102     void SendFinishedFailure();
103     void SaveExceptionData(const Jobs::JobExceptionBase&);
104 };
105 } //namespace WidgetInstall
106 } //namespace Jobs
107
108 #endif // WRT_SRC_INSTALLER_CORE_JOB_JOB_WIDGET_INSTALL_H_