tizen beta release
[framework/web/wrt-installer.git] / src / misc / feature_logic.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 #ifndef SRC_INSTALLER_MISC_FEATURE_LOGIC
18 #define SRC_INSTALLER_MISC_FEATURE_LOGIC
19
20 #include <list>
21 #include <string>
22
23 #include <dpl/assert.h>
24 #include <dpl/noncopyable.h>
25 #include <dpl/shared_ptr.h>
26
27 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
28 #include <wrt_common_types.h>
29
30 namespace Jobs {
31 namespace WidgetInstall {
32
33 class FeatureLogic : DPL::Noncopyable {
34   public:
35
36     FeatureLogic(WidgetHandle handle);
37
38     bool isDone() const;
39
40     bool next();
41
42     void setAceResponse(bool allowed);
43
44     DPL::String getDevice() const;
45
46     bool isRejected(void) const
47     {
48         return m_rejected;
49     }
50
51   private:
52     bool isProcessable() const;
53
54     struct Feature : public WidgetFeature {
55         WrtDB::DeviceCapabilitySet devCapSet;
56         WrtDB::DeviceCapabilitySet::const_iterator currentCap;
57         bool rejected;
58
59         Feature(const WidgetFeature &wf, const WrtDB::DeviceCapabilitySet &set)
60           : WidgetFeature(wf)
61           , devCapSet(set)
62           , rejected(false)
63         {
64             currentCap = devCapSet.begin();
65         }
66
67         explicit Feature(const Feature &second) : WidgetFeature(second)
68         {
69             devCapSet = second.devCapSet;
70             currentCap = devCapSet.find(*second.currentCap);
71             rejected = second.rejected;
72         }
73       private:
74         void operator=(const Feature &second) {
75             name = second.name;
76             devCapSet = second.devCapSet;
77             required = second.required;
78             rejected = second.rejected;
79             pluginId = second.pluginId;
80             params = second.params;
81             currentCap = devCapSet.find(*second.currentCap);
82         }
83     };
84     typedef std::list<Feature> FeatureList;
85
86     FeatureList m_featureList;
87     FeatureList::iterator m_currentFeature;
88     bool m_rejected;
89 };
90
91 typedef DPL::SharedPtr<FeatureLogic> FeatureLogicPtr;
92
93 } // namespace WidgetInstall
94 } // namespace Jobs
95
96 #endif // SRC_INSTALLER_MISC_FEATURE_LOGIC