tizen beta release
[framework/web/wrt-installer.git] / src / jobs / job.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 #ifndef INSTALLER_MODEL_H
17 #define INSTALLER_MODEL_H
18
19 #include <dpl/task_list.h>
20
21 namespace Jobs {
22 class JobExceptionBase;
23 /**
24  * @brief Defines installation and uninstallation type.
25  */
26 enum InstallationType
27 {
28     Installation, ///< defines install process
29     Uninstallation, ///< defines uninstall process
30     PluginInstallation ///< defines plugin installation process
31 };
32
33 typedef int JobHandle;
34
35 class Job :
36     public DPL::TaskList
37 {
38   public:
39     Job(InstallationType installType);
40
41     InstallationType GetInstallationType() const;
42
43     // Undo
44     void SetUndoType(bool flag);
45     bool GetUndoType() const;
46
47     // Pause/resume support
48     bool IsPaused() const;
49     void SetPaused(bool paused);
50     void Pause();
51     void Resume();
52     void SetJobHandle(JobHandle handle);
53     JobHandle GetJobHandle() const;
54     virtual void SendProgress();
55     virtual void SendFinishedSuccess();
56     virtual void SendFinishedFailure();
57
58     virtual void SaveExceptionData(const Jobs::JobExceptionBase&);
59   private:
60     JobHandle m_handle;
61     InstallationType m_installationType;
62     bool m_UndoType; //TODO change name to m_AbortStarted
63     bool m_paused;
64 };
65 } //namespace Jobs
66
67 #endif // INSTALLER_MODEL_H