upload tizen1.0 source
[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 "widget_installer_struct.h"
34
35 namespace Jobs {
36 namespace WidgetInstall {
37 class JobWidgetInstall :
38     public Job,
39     public JobProgressBase<InstallerContext::InstallStep,
40                            InstallerContext::INSTALL_END>,
41     public JobContextBase<WidgetInstallationStruct>   //TODO typedef
42 {
43   private:
44     typedef DPL::Optional<WidgetHandle> OptionalWidgetHandle;
45
46     InstallerContext m_installerContext;
47
48     //TODO move it to base class of all jobs
49     Exceptions::Type m_exceptionCaught;
50     std::string m_exceptionMessage;
51     WidgetUpdateInfo m_widgetUpdateInfo;
52
53     enum class ConfigureResult
54     {
55         Ok, Failed, Deferred
56     };
57
58     ConfigureResult ConfigureInstallation(const std::string &widgetSource,
59                                           bool fromBrowser);
60     WidgetUpdateInfo detectWidgetUpdate(const std::string &widgetSource,
61                                         bool fromBrowser);
62     WidgetUpdateMode::Type CalcWidgetUpdatePolicy(
63             const OptionalWidgetVersion &existingVersion,
64             const OptionalWidgetVersion &incomingVersion) const;
65     void displayWidgetInfo();
66
67   public:
68     /**
69      * @brief Automaticaly sets installation process
70      */
71     JobWidgetInstall(std::string const & widgetPath,
72             const WidgetInstallationStruct &installerStruct);
73     /**
74      * @brief Automaticaly sets installation process from browser
75      */
76     JobWidgetInstall(std::string const & widgetUrl,
77                      std::string const & iconPath,
78                      const WidgetInstallationStruct &installerStruct);
79
80     DPL::Optional<WidgetHandle> getNewWidgetHandle() const;
81
82     //overrides
83     void SendProgress();
84     void SendFinishedSuccess();
85     void SendFinishedFailure();
86     void SaveExceptionData(const Jobs::JobExceptionBase&);
87 };
88 } //namespace WidgetInstall
89 } //namespace Jobs
90
91 #endif // WRT_SRC_INSTALLER_CORE_JOB_JOB_WIDGET_INSTALL_H_