Platform version check during wgt installation
[framework/web/wrt-installer.git] / src / jobs / widget_install / widget_installer_struct.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    widget_installer_struct.h
18  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19  * @author  Grzegorz Krawczyk (g.krawczyk@samsung.com)
20  * @version 1.0
21  * @brief   Implementation file for widget installer struct
22  */
23 #ifndef WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
24 #define WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
25
26 //SYSTEM INCLUDES
27 #include <dpl/assert.h>
28
29 //WRT INCLUDES
30 #include <job_base.h>
31 #include <job.h>
32 #include <widget_install/widget_install_errors.h>
33 #include <wrt_common_types.h>
34 #include <string>
35
36 //Widget Installer typedefs
37 typedef void (*InstallerFinishedCallback)(
38     void *userParam,
39     std::string tizenId,
40     Jobs::WidgetInstall::Exceptions::Type);
41
42 typedef void (*InstallerProgressCallback)(void *userParam,
43                                           ProgressPercent percent,
44                                           const ProgressDescription &);
45
46 namespace WidgetUpdateMode {
47 enum Type
48 {
49     Zero = 0,
50
51     // Bits
52     NotInstalled          = 1 << 0,
53     IncomingVersionNotStd = 1 << 1,
54     ExistingVersionNotStd = 1 << 2,
55     BothVersionsNotStd    = 1 << 3,
56     ExistingVersionOlder  = 1 << 4,
57     ExistingVersionEqual  = 1 << 5,
58     ExistingVersionNewer  = 1 << 6,
59
60     // Policies
61     PolicyNeverUpdate = NotInstalled,
62
63     PolicyWac = NotInstalled |
64         ExistingVersionOlder,
65
66     PolicyAlwaysInstall = NotInstalled |
67         IncomingVersionNotStd |
68         ExistingVersionNotStd |
69         BothVersionsNotStd |
70         ExistingVersionOlder |
71         ExistingVersionEqual |
72         ExistingVersionNewer,
73
74     PolicyForceInstall = PolicyAlwaysInstall
75 };
76
77 inline Type operator | (const Type &a,
78         const Type &b)
79 {
80     return static_cast<Type>(static_cast<unsigned long>(a) |
81                              static_cast<unsigned long>(b));
82 }
83
84 inline Type operator & (const Type &a,
85         const Type &b)
86 {
87     return static_cast<Type>(static_cast<unsigned long>(a) &
88                              static_cast<unsigned long>(b));
89 }
90 }
91
92 //TODO into namespace
93 //InstallationStruct
94 typedef Jobs::JobCallbacksBase<InstallerFinishedCallback,
95                                InstallerProgressCallback>
96 WidgetInstallCallbackBase;
97
98 //Widget Installation Struct
99 struct WidgetInstallationStruct : public WidgetInstallCallbackBase
100 {
101     WidgetUpdateMode::Type updateMode;
102     bool m_quiet;
103
104     // It must be empty-constructible as a parameter of generic event
105     WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
106                                 m_quiet(false)
107     {
108     }
109
110     WidgetInstallationStruct(InstallerFinishedCallback finished,
111             InstallerProgressCallback progress,
112             void *param,
113             WidgetUpdateMode::Type mode,
114             bool quiet) :
115         WidgetInstallCallbackBase(finished, progress, param),
116         updateMode(mode),
117         m_quiet(quiet)
118     {
119     }
120 };
121
122 #endif // WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_