[Release] wrt-installer_0.1.85
[platform/framework/web/wrt-installer.git] / src / jobs / plugin_install / job_plugin_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_plugin_install.h
18  * @author  Pawel Sikorski (p.sikorski@samgsung.com)
19  * @version
20  * @brief
21  */
22
23 #ifndef WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_
24 #define WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_
25
26 //SYSTEM INCLUDES
27 #include <string>
28
29 //WRT INCLUDES
30 #include <job.h>
31 #include <job_base.h>
32 #include <plugin_install/plugin_installer_struct.h>
33 #include <plugin_install/plugin_installer_context.h>
34 #include <dpl/utils/path.h>
35
36 namespace Jobs {
37 namespace PluginInstall {
38 class JobPluginInstall :
39     public Job,
40     public JobProgressBase<PluginInstallerContext::PluginInstallStep,
41                            PluginInstallerContext::PLUGIN_INSTALL_END>,
42     public JobContextBase<PluginInstallerStruct>
43 {
44   public:
45     static const WrtDB::DbPluginHandle INVALID_HANDLE = -1;
46
47   public:
48     /**
49      * @brief Automaticaly sets installation process
50      */
51     JobPluginInstall(DPL::Utils::Path const &pluginPath,
52                      const PluginInstallerStruct &installerStruct);
53
54     WrtDB::DbPluginHandle getNewPluginHandle() const
55     {
56         return m_context.pluginHandle;
57     }
58     std::string getFilePath() const
59     {
60         return m_context.pluginFilePath.Fullpath();
61     }
62     bool isReadyToInstall() const
63     {
64         return m_context.installationCompleted;
65     }
66
67     void SendProgress();
68     void SendFinishedSuccess();
69     void SendFinishedFailure();
70     void SaveExceptionData(const Jobs::JobExceptionBase &e);
71
72   private:
73     //TODO move somewhere this attribute
74     //(as it is in all Jobs...)
75     PluginInstallerContext m_context;
76
77     //TODO move it to base class of all jobs
78     //maybe separate JobBase class for this?
79     Jobs::Exceptions::Type m_exceptionCaught;
80     std::string m_exceptionMessage;
81 };
82 } //namespace Jobs
83 } //namespace PluginInstall
84
85 #endif /* WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_ */