2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "feature_logic.h"
21 #include <dpl/assert.h>
22 #include <dpl/noncopyable.h>
23 #include <dpl/string.h>
24 #include <dpl/foreach.h>
26 #include <dpl/wrt-dao-rw/widget_dao.h>
27 #include <dpl/wrt-dao-rw/global_dao.h>
30 namespace WidgetInstall {
32 FeatureLogic::FeatureLogic(WidgetHandle handle)
35 WrtDB::WidgetDAO widgetDao(handle);
36 WidgetFeatureSet featureSet = widgetDao.getFeaturesList();
37 FOREACH(it, featureSet) {
38 WrtDB::DeviceCapabilitySet dcs =
39 WrtDB::GlobalDAO::GetDeviceCapability(it->name);
40 Feature feature(*it, dcs);
41 m_featureList.push_back(feature);
43 m_currentFeature = m_featureList.begin();
45 // ok we must set iterator on the first processable node
46 if (!isProcessable()) {
51 bool FeatureLogic::isDone() const
53 return m_currentFeature == m_featureList.end();
56 bool FeatureLogic::next()
59 if (m_currentFeature->currentCap != m_currentFeature->devCapSet.end()) {
60 m_currentFeature->currentCap++;
65 if (isProcessable()) {
73 void FeatureLogic::setAceResponse(bool allowed)
75 Assert(isProcessable() && "Wrong usage");
77 m_currentFeature->rejected = true;
78 if (m_currentFeature->required) {
84 DPL::String FeatureLogic::getDevice() const
86 return *(m_currentFeature->currentCap);
89 bool FeatureLogic::isProcessable() const
95 if (m_currentFeature->currentCap == m_currentFeature->devCapSet.end()) {
102 } // namespace WidgetInstall