Direcotry install feature added to wrt-installer
[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     PolicyDirectoryForceInstall
76 };
77
78 inline Type operator | (const Type &a,
79         const Type &b)
80 {
81     return static_cast<Type>(static_cast<unsigned long>(a) |
82                              static_cast<unsigned long>(b));
83 }
84
85 inline Type operator & (const Type &a,
86         const Type &b)
87 {
88     return static_cast<Type>(static_cast<unsigned long>(a) &
89                              static_cast<unsigned long>(b));
90 }
91 }
92
93 //TODO into namespace
94 //InstallationStruct
95 typedef Jobs::JobCallbacksBase<InstallerFinishedCallback,
96                                InstallerProgressCallback>
97 WidgetInstallCallbackBase;
98
99 //Widget Installation Struct
100 struct WidgetInstallationStruct : public WidgetInstallCallbackBase
101 {
102     WidgetUpdateMode::Type updateMode;
103     bool m_quiet;
104
105     // It must be empty-constructible as a parameter of generic event
106     WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
107                                 m_quiet(true)
108     {
109     }
110
111     WidgetInstallationStruct(InstallerFinishedCallback finished,
112             InstallerProgressCallback progress,
113             void *param,
114             WidgetUpdateMode::Type mode,
115             bool quiet) :
116         WidgetInstallCallbackBase(finished, progress, param),
117         updateMode(mode),
118         m_quiet(quiet)
119     {
120     }
121 };
122
123 #endif // WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_