tizen beta release
[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
35 namespace Jobs {
36 namespace PluginInstall {
37 class JobPluginInstall :
38     public Job,
39     public JobProgressBase<PluginInstallerContext::PluginInstallStep,
40                            PluginInstallerContext::PLUGIN_INSTALL_END>,
41     public JobContextBase<PluginInstallerStruct>
42 {
43   public:
44     static const WrtDB::DbPluginHandle INVALID_HANDLE = -1;
45
46   public:
47     /**
48      * @brief Automaticaly sets installation process
49      */
50     JobPluginInstall(std::string const &pluginPath,
51             const PluginInstallerStruct &installerStruct);
52
53     WrtDB::DbPluginHandle getNewPluginHandle() const
54     {
55         return m_context.pluginHandle;
56     }
57     std::string getFilePath() const
58     {
59         return m_context.pluginFilePath;
60     }
61     bool isReadyToInstall() const
62     {
63         return m_context.installationCompleted;
64     }
65
66     void SendProgress();
67     void SendFinishedSuccess();
68     void SendFinishedFailure();
69     void SaveExceptionData(const Jobs::JobExceptionBase &e);
70   private:
71     //TODO move somewhere this attribute
72     //(as it is in all Jobs...)
73     PluginInstallerContext m_context;
74
75     //TODO move it to base class of all jobs
76     //maybe separate JobBase class for this?
77     Exceptions::Type m_exceptionCaught;
78     std::string m_exceptionMessage;
79 };
80 } //namespace Jobs
81 } //namespace PluginInstall
82
83 #endif /* WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_ */