Initialize Tizen 2.3
[framework/web/wrt-installer.git] / src_wearable / 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 <memory>
26
27 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
28 #include <wrt_common_types.h>
29
30 namespace Jobs {
31 namespace WidgetInstall {
32 class FeatureLogic : DPL::Noncopyable
33 {
34   public:
35
36     FeatureLogic(const WrtDB::TizenAppId & tzAppid);
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     struct Feature : public WidgetFeature {
52         WrtDB::DeviceCapabilitySet devCapSet;
53         WrtDB::DeviceCapabilitySet::const_iterator currentCap;
54
55         Feature(const WidgetFeature &wf,
56                 const WrtDB::DeviceCapabilitySet &set) :
57             WidgetFeature(wf)
58             , devCapSet(set)
59         {
60             currentCap = devCapSet.begin();
61         }
62
63         explicit Feature(const Feature &second) : WidgetFeature(second)
64         {
65             devCapSet = second.devCapSet;
66             currentCap = devCapSet.find(*second.currentCap);
67             rejected = second.rejected;
68         }
69
70       private:
71         void operator=(const Feature &second)
72         {
73             name = second.name;
74             devCapSet = second.devCapSet;
75             rejected = second.rejected;
76             pluginId = second.pluginId;
77             currentCap = devCapSet.find(*second.currentCap);
78         }
79     };
80
81     typedef std::list<Feature> FeatureList;
82     typedef FeatureList::const_iterator FeatureIterator;
83
84     FeatureIterator resultBegin()
85     {
86         return m_featureList.begin();
87     }
88     FeatureIterator resultEnd()
89     {
90         return m_featureList.end();
91     }
92
93   private:
94     bool isProcessable() const;
95
96     FeatureList m_featureList;
97     FeatureList::iterator m_currentFeature;
98     bool m_rejected;
99 };
100
101 typedef std::shared_ptr<FeatureLogic> FeatureLogicPtr;
102 } // namespace WidgetInstall
103 } // namespace Jobs
104
105 #endif // SRC_INSTALLER_MISC_FEATURE_LOGIC