tizen beta release
[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
35 //Widget Installer typedefs
36 typedef void (*InstallerFinishedCallback)(
37     void *userParam,
38     WidgetHandle,
39     Jobs::WidgetInstall::Exceptions::Type);
40
41 typedef void (*InstallerProgressCallback)(void *userParam,
42                                           ProgressPercent percent,
43                                           const ProgressDescription &);
44
45 namespace WidgetUpdateMode {
46 enum Type
47 {
48     Zero = 0,
49
50     // Bits
51     NotInstalled          = 1 << 0,
52     IncomingVersionNotStd = 1 << 1,
53     ExistingVersionNotStd = 1 << 2,
54     BothVersionsNotStd    = 1 << 3,
55     ExistingVersionOlder  = 1 << 4,
56     ExistingVersionEqual  = 1 << 5,
57     ExistingVersionNewer  = 1 << 6,
58
59     // Policies
60     PolicyNeverUpdate = NotInstalled,
61
62     PolicyWac = NotInstalled |
63         ExistingVersionOlder,
64
65     PolicyAlwaysInstall = NotInstalled |
66         IncomingVersionNotStd |
67         ExistingVersionNotStd |
68         BothVersionsNotStd |
69         ExistingVersionOlder |
70         ExistingVersionEqual |
71         ExistingVersionNewer,
72
73     PolicyForceInstall = PolicyAlwaysInstall
74 };
75
76 inline Type operator | (const Type &a,
77         const Type &b)
78 {
79     return static_cast<Type>(static_cast<unsigned long>(a) |
80                              static_cast<unsigned long>(b));
81 }
82
83 inline Type operator & (const Type &a,
84         const Type &b)
85 {
86     return static_cast<Type>(static_cast<unsigned long>(a) &
87                              static_cast<unsigned long>(b));
88 }
89 }
90
91 //TODO into namespace
92 //InstallationStruct
93 typedef Jobs::JobCallbacksBase<InstallerFinishedCallback,
94                                InstallerProgressCallback>
95 WidgetInstallCallbackBase;
96
97 //Widget Installation Struct
98 struct WidgetInstallationStruct : public WidgetInstallCallbackBase
99 {
100     WidgetUpdateMode::Type updateMode;
101
102     // It must be empty-constructible as a parameter of generic event
103     WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero)
104     {
105     }
106
107     WidgetInstallationStruct(InstallerFinishedCallback finished,
108             InstallerProgressCallback progress,
109             void *param,
110             WidgetUpdateMode::Type mode) :
111         WidgetInstallCallbackBase(finished, progress, param),
112         updateMode(mode)
113     {
114     }
115 };
116
117 #endif // WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_