tizen 2.4 release
[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 <job.h>
27 #include <job_base.h>
28 #include <dpl/utils/widget_version.h>
29 #include "widget_installer_struct.h"
30 #include <widget_install/widget_install_context.h>
31 #include <widget_install/widget_unzip.h>
32 #include <boost/filesystem.hpp>
33
34 namespace bf = boost::filesystem;
35 using namespace Jobs::Exceptions;
36
37 namespace Jobs {
38 namespace WidgetInstall {
39
40 typedef JobProgressBase<InstallerContext::InstallStep, InstallerContext::INSTALL_END> InstallerBase;
41 typedef JobContextBase<Jobs::WidgetInstall::WidgetInstallationStruct> WidgetInstallationBase;
42
43 class JobWidgetInstall :
44     public Job,
45     public InstallerBase,
46     public WidgetInstallationBase
47
48 {
49   private:
50
51     Jobs::Exceptions::Type m_exceptionCaught;
52     std::string m_exceptionMessage;
53
54   public:
55       InstallerContext m_installerContext;
56     /**
57      * @brief Automaticaly sets installation process
58      */
59     JobWidgetInstall(std::string const & widgetPath,
60          std::string const &tzPkgId,
61          const Jobs::WidgetInstall::WidgetInstallationStruct &installerStruct);
62
63     //Widget Unzip Object
64     std::shared_ptr<WidgetUnzip> m_wgtUnzip;
65
66     //overrides
67     void SendProgress();
68     void SendFinishedSuccess();
69     void SendFinishedFailure();
70     void SendProgressIconPath(const std::string &path);
71
72     void SaveExceptionData(const Jobs::JobExceptionBase&);
73     void displayWidgetInfo();
74
75     //execution paths
76     void appendNewInstallationTaskList();
77     void appendUpdateInstallationTaskList();
78     void appendRDSUpdateTaskList();
79     void appendRecoveryTaskList();
80     void appendFotaInstallationTaskList();
81     void appendFotaUpdateTaskList();
82
83     static void SecureRemove(const bf::path& path);
84 };
85 } //namespace WidgetInstall
86 } //namespace Jobs
87
88 #endif // WRT_SRC_INSTALLER_CORE_JOB_JOB_WIDGET_INSTALL_H_